summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/vm/child-qsort.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/tests/vm/child-qsort.c
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/tests/vm/child-qsort.c')
-rw-r--r--pintos-progos/tests/vm/child-qsort.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/pintos-progos/tests/vm/child-qsort.c b/pintos-progos/tests/vm/child-qsort.c
new file mode 100644
index 0000000..355f4eb
--- /dev/null
+++ b/pintos-progos/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}