14#define CHUNK_SIZE (126 * 512)
16#define DATA_SIZE (CHUNK_CNT * CHUNK_SIZE)
33 for (
i = 0;
i <
sizeof buf1;
i++)
49 msg (
"sort chunk %zu",
i);
53 CHECK ((handle =
open (
"buffer")) > 1,
"open \"buffer\"");
58 CHECK ((child =
exec (
"child-sort buffer")) != -1,
59 "exec \"child-sort buffer\"");
60 CHECK (
wait (child) == 123,
"wait for child-sort");
63 CHECK ((handle =
open (
"buffer")) > 1,
"open \"buffer\"");
93 for (
i = 1;
i < mp_left;
i++)
94 if (*mp[
i] < *mp[min])
103 mp[min] = mp[--mp_left];
121 if (
buf2[buf_idx] != hist_idx)
122 fail (
"bad value %d in byte %zu",
buf2[buf_idx], buf_idx);
127 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)
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.
static void init(void)
Initialize buf1 with random data, then count the number of instances of each value within it.
unsigned char buf2[DATA_SIZE]
static void sort_chunks(void)
Sort each chunk of buf1 using a subprocess.
static void merge(void)
Merge the sorted chunks in buf1 into a fully sorted buf2.
void test_main(void)
tests/main.h
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.