13#define CHUNK_SIZE (128 * 1024)
15#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE)
32 for (
i = 0;
i <
sizeof buf1;
i++)
50 msg (
"sort chunk %zu",
i);
56 CHECK ((handle =
open (fn)) > 1,
"open \"%s\"", fn);
61 snprintf (cmd,
sizeof cmd,
"%s %s", subprocess, fn);
62 CHECK ((children[
i] =
exec (cmd)) != -1,
"exec \"%s\"", cmd);
71 CHECK (
wait (children[
i]) == exit_status,
"wait for child %zu",
i);
76 CHECK ((handle =
open (fn)) > 1,
"open \"%s\"", fn);
105 for (
i = 1;
i < mp_left;
i++)
106 if (*mp[
i] < *mp[min])
115 mp[min] = mp[--mp_left];
133 if (
buf2[buf_idx] != hist_idx)
134 fail (
"bad value %d in byte %zu",
buf2[buf_idx], buf_idx);
139 msg (
"success, buf_idx=%'zu", buf_idx);
void arc4_init(struct arc4 *arc4, const void *key_, size_t size)
void arc4_crypt(struct arc4 *arc4, void *buf_, size_t size)
tests/arc4.h
static void wait(struct intq *q, struct thread **waiter)
int snprintf(char *buffer, size_t buf_size, const char *format,...)
Like printf(), except that output is stored into BUFFER, which must have space for BUF_SIZE character...
bool create(const char *file, unsigned initial_size)
int open(const char *file)
int write(int fd, const void *buffer, unsigned size)
pid_t exec(const char *file)
int read(int fd, void *buffer, unsigned size)
int pid_t
Process identifier.
void fail(const char *format,...)
void msg(const char *format,...)
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
void parallel_merge(const char *child_name, int exit_status)
tests/vm/parallel-merge.h
static void init(void)
Initialize buf1 with random data, then count the number of instances of each value within it.
static void sort_chunks(const char *subprocess, int exit_status)
Sort each chunk of buf1 using SUBPROCESS, which is expected to return EXIT_STATUS.
unsigned char buf2[DATA_SIZE]
static void merge(void)
Merge the sorted chunks in buf1 into a fully sorted buf2.
unsigned char buf1[DATA_SIZE]
#define CHUNK_SIZE
Generates about 1 MB of random data that is then divided into 16 chunks.
#define CHUNK_CNT
Number of chunks.
#define DATA_SIZE
Buffer size.
Alleged RC4 algorithm encryption state.