Commit 7fb9a24e3925cecc4b6e4a47a27c2caba077b2f6

Authored by bellard
1 parent afeb6ee3

update


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@92 c046a42c-6fe2-441c-8c8c-71466251a162
tests/.cvsignore 0 → 100644
  1 + gmon.out
  2 + testsig
  3 + hello
  4 + sha1.test.c
  5 + sha1.c
  6 + op.c
  7 + test-i386
  8 + sha1
  9 + testclone
  10 + interp.h
  11 + interploop.c
  12 + .gdb_history
  13 + cachegrind.out
  14 + interp.c
  15 + interp
  16 + testthread
  17 + test-i386.s
  18 + test-i386.ref
  19 + sha1-i386
  20 + runcom
  21 + debug.com
  22 + test-i386.out
  23 + speed.txt
  24 + test-i386.ref.P3
  25 + pi_10.com
  26 + test-i386.ref.P4
  27 + ldso.c
  28 + test_path
... ...
tests/Makefile
... ... @@ -6,7 +6,7 @@ LDFLAGS=
6 6 ifeq ($(ARCH),i386)
7 7 TESTS=testclone testsig testthread sha1-i386 test-i386 runcom
8 8 endif
9   -TESTS+=sha1
  9 +TESTS+=sha1 test_path
10 10  
11 11 QEMU=../qemu
12 12  
... ... @@ -25,6 +25,10 @@ testsig: testsig.c
25 25 testthread: testthread.c
26 26 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
27 27  
  28 +test_path: test_path.c
  29 + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
  30 + ./$@ || { rm $@; exit 1; }
  31 +
28 32 # i386 emulation test (test various opcodes) */
29 33 test-i386: test-i386.c test-i386-code16.S \
30 34 test-i386.h test-i386-shift.h test-i386-muldiv.h
... ...
tests/runcom.c
... ... @@ -3,6 +3,7 @@
3 3 */
4 4 #include <stdlib.h>
5 5 #include <stdio.h>
  6 +#include <string.h>
6 7 #include <inttypes.h>
7 8 #include <unistd.h>
8 9 #include <fcntl.h>
... ... @@ -14,6 +15,12 @@
14 15  
15 16 //#define SIGTEST
16 17  
  18 +#undef __syscall_return
  19 +#define __syscall_return(type, res) \
  20 +do { \
  21 + return (type) (res); \
  22 +} while (0)
  23 +
17 24 _syscall2(int, vm86, int, func, struct vm86plus_struct *, v86)
18 25  
19 26 #define COM_BASE_ADDR 0x10100
... ...
tests/test_path.c 0 → 100644
  1 +/* Test path override code */
  2 +#define _GNU_SOURCE
  3 +#include "../path.c"
  4 +#include <stdarg.h>
  5 +#include <sys/stat.h>
  6 +#include <fcntl.h>
  7 +
  8 +/* Any log message kills the test. */
  9 +void gemu_log(const char *fmt, ...)
  10 +{
  11 + va_list ap;
  12 +
  13 + fprintf(stderr, "FATAL: ");
  14 + va_start(ap, fmt);
  15 + vfprintf(stderr, fmt, ap);
  16 + va_end(ap);
  17 + exit(1);
  18 +}
  19 +
  20 +#define NO_CHANGE(_path) \
  21 + do { \
  22 + if (strcmp(path(_path), _path) != 0) return __LINE__; \
  23 + } while(0)
  24 +
  25 +#define CHANGE_TO(_path, _newpath) \
  26 + do { \
  27 + if (strcmp(path(_path), _newpath) != 0) return __LINE__; \
  28 + } while(0)
  29 +
  30 +static void cleanup(void)
  31 +{
  32 + unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE");
  33 + unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE2");
  34 + unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE3");
  35 + unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE4");
  36 + unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE5");
  37 + rmdir("/tmp/qemu-test_path/DIR1/DIR2");
  38 + rmdir("/tmp/qemu-test_path/DIR1/DIR3");
  39 + rmdir("/tmp/qemu-test_path/DIR1");
  40 + rmdir("/tmp/qemu-test_path");
  41 +}
  42 +
  43 +static unsigned int do_test(void)
  44 +{
  45 + if (mkdir("/tmp/qemu-test_path", 0700) != 0)
  46 + return __LINE__;
  47 +
  48 + if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0)
  49 + return __LINE__;
  50 +
  51 + if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0)
  52 + return __LINE__;
  53 +
  54 + if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0)
  55 + return __LINE__;
  56 +
  57 + if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0)
  58 + return __LINE__;
  59 +
  60 + if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0)
  61 + return __LINE__;
  62 +
  63 + if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0)
  64 + return __LINE__;
  65 +
  66 + if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0)
  67 + return __LINE__;
  68 +
  69 + if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0)
  70 + return __LINE__;
  71 +
  72 + init_paths("/tmp/qemu-test_path");
  73 +
  74 + NO_CHANGE("/tmp");
  75 + NO_CHANGE("/tmp/");
  76 + NO_CHANGE("/tmp/qemu-test_path");
  77 + NO_CHANGE("/tmp/qemu-test_path/");
  78 + NO_CHANGE("/tmp/qemu-test_path/D");
  79 + NO_CHANGE("/tmp/qemu-test_path/DI");
  80 + NO_CHANGE("/tmp/qemu-test_path/DIR");
  81 + NO_CHANGE("/tmp/qemu-test_path/DIR1");
  82 + NO_CHANGE("/tmp/qemu-test_path/DIR1/");
  83 +
  84 + NO_CHANGE("/D");
  85 + NO_CHANGE("/DI");
  86 + NO_CHANGE("/DIR");
  87 + NO_CHANGE("/DIR2");
  88 + NO_CHANGE("/DIR1.");
  89 +
  90 + CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1");
  91 + CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1");
  92 +
  93 + NO_CHANGE("/DIR1/D");
  94 + NO_CHANGE("/DIR1/DI");
  95 + NO_CHANGE("/DIR1/DIR");
  96 + NO_CHANGE("/DIR1/DIR1");
  97 +
  98 + CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
  99 + CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2");
  100 +
  101 + CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3");
  102 + CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3");
  103 +
  104 + NO_CHANGE("/DIR1/DIR2/F");
  105 + NO_CHANGE("/DIR1/DIR2/FI");
  106 + NO_CHANGE("/DIR1/DIR2/FIL");
  107 + NO_CHANGE("/DIR1/DIR2/FIL.");
  108 +
  109 + CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  110 + CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2");
  111 + CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3");
  112 + CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4");
  113 + CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5");
  114 +
  115 + NO_CHANGE("/DIR1/DIR2/FILE6");
  116 + NO_CHANGE("/DIR1/DIR2/FILE/X");
  117 +
  118 + CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1");
  119 + CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1");
  120 + CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1");
  121 + CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1");
  122 + CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2");
  123 + CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  124 + CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  125 +
  126 + NO_CHANGE("/DIR1/DIR2/../DIR1");
  127 + NO_CHANGE("/DIR1/DIR2/../FILE");
  128 +
  129 + CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  130 + CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  131 + CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  132 + CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  133 + CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  134 + CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  135 + CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE");
  136 +
  137 + return 0;
  138 +}
  139 +
  140 +int main(int argc, char *argv[])
  141 +{
  142 + int ret;
  143 +
  144 + ret = do_test();
  145 + cleanup();
  146 + if (ret) {
  147 + fprintf(stderr, "test_path: failed on line %i\n", ret);
  148 + return 1;
  149 + }
  150 + return 0;
  151 +}
  152 +
... ...
tests/testclone.c
1 1 #include <stdlib.h>
2 2 #include <stdio.h>
  3 +#include <string.h>
3 4 #include <signal.h>
4 5 #include <unistd.h>
5 6 #include <inttypes.h>
... ...
tests/testthread.c
1 1 #include <stdlib.h>
2 2 #include <stdio.h>
  3 +#include <string.h>
3 4 #include <signal.h>
4 5 #include <unistd.h>
5 6 #include <inttypes.h>
... ...