summaryrefslogtreecommitdiffstats
path: root/tests/vm/child-qsort.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/vm/child-qsort.c
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/vm/child-qsort.c')
-rw-r--r--tests/vm/child-qsort.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/vm/child-qsort.c b/tests/vm/child-qsort.c
new file mode 100644
index 0000000..355f4eb
--- /dev/null
+++ b/tests/vm/child-qsort.c
@@ -0,0 +1,32 @@
1/* Reads a 128 kB file onto the stack and "sorts" the bytes in
2 it, using quick sort, a multi-pass divide and conquer
3 algorithm. The sorted data is written back to the same file
4 in-place. */
5
6#include <debug.h>
7#include <syscall.h>
8#include "tests/lib.h"
9#include "tests/main.h"
10#include "tests/vm/qsort.h"
11
12const char *test_name = "child-qsort";
13
14int
15main (int argc UNUSED, char *argv[])
16{
17 int handle;
18 unsigned char buf[128 * 1024];
19 size_t size;
20
21 quiet = true;
22
23 CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]);
24
25 size = read (handle, buf, sizeof buf);
26 qsort_bytes (buf, sizeof buf);
27 seek (handle, 0);
28 write (handle, buf, size);
29 close (handle);
30
31 return 72;
32}