diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-10-27 23:58:04 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-10-27 23:58:04 +0000 |
commit | 285dc330bd28aa0e097106875bb184e2707bbed5 (patch) | |
tree | 76c92ab616914b2da4c4c135ba9a31b4223d730e /tests | |
parent | baf8ebf01a70782d222f0eaf29591dc60723f73c (diff) | |
download | qemu-285dc330bd28aa0e097106875bb184e2707bbed5.tar.gz qemu-285dc330bd28aa0e097106875bb184e2707bbed5.tar.bz2 qemu-285dc330bd28aa0e097106875bb184e2707bbed5.zip |
update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@417 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests')
-rw-r--r-- | tests/linux-test.c | 5 | ||||
-rw-r--r-- | tests/testclone.c | 62 | ||||
-rw-r--r-- | tests/testsig.c | 194 |
3 files changed, 2 insertions, 259 deletions
diff --git a/tests/linux-test.c b/tests/linux-test.c index 3ced0dd69a..14cbe1385e 100644 --- a/tests/linux-test.c +++ b/tests/linux-test.c @@ -71,7 +71,7 @@ int __chk_error(const char *filename, int line, int ret) #define FILE_BUF_SIZE 300 -void file_test(void) +void test_file(void) { int fd, i, len, ret; uint8_t buf[FILE_BUF_SIZE]; @@ -499,7 +499,7 @@ void test_signal(void) int main(int argc, char **argv) { - file_test(); + test_file(); test_fork(); test_time(); test_socket(); @@ -507,4 +507,3 @@ int main(int argc, char **argv) test_signal(); return 0; } - diff --git a/tests/testclone.c b/tests/testclone.c deleted file mode 100644 index 531bd5c610..0000000000 --- a/tests/testclone.c +++ /dev/null @@ -1,62 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <signal.h> -#include <unistd.h> -#include <inttypes.h> -#include <pthread.h> -#include <sys/wait.h> -#include <sched.h> - -int thread1_func(void *arg) -{ - int i; - char buf[512]; - - for(i=0;i<10;i++) { - snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); - usleep(100 * 1000); - } - return 0; -} - -int thread2_func(void *arg) -{ - int i; - char buf[512]; - for(i=0;i<20;i++) { - snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); - usleep(120 * 1000); - } - return 0; -} - -#define STACK_SIZE 16384 - -void test_clone(void) -{ - uint8_t *stack1, *stack2; - int pid1, pid2, status1, status2; - - stack1 = malloc(STACK_SIZE); - pid1 = clone(thread1_func, stack1 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1"); - - stack2 = malloc(STACK_SIZE); - pid2 = clone(thread2_func, stack2 + STACK_SIZE, - CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2"); - - while (waitpid(pid1, &status1, 0) != pid1); - while (waitpid(pid2, &status2, 0) != pid2); - printf("status1=0x%x\n", status1); - printf("status2=0x%x\n", status2); - printf("End of clone test.\n"); -} - -int main(int argc, char **argv) -{ - test_clone(); - return 0; -} diff --git a/tests/testsig.c b/tests/testsig.c deleted file mode 100644 index 2eb2bfc4ac..0000000000 --- a/tests/testsig.c +++ /dev/null @@ -1,194 +0,0 @@ -#define _GNU_SOURCE -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <signal.h> -#include <unistd.h> -#include <setjmp.h> -#include <sys/ucontext.h> - -jmp_buf jmp_env; - -void alarm_handler(int sig) -{ - printf("alarm signal=%d\n", sig); - alarm(1); -} - -#ifndef REG_EAX -#define REG_EAX EAX -#define REG_EBX EBX -#define REG_ECX ECX -#define REG_EDX EDX -#define REG_ESI ESI -#define REG_EDI EDI -#define REG_EBP EBP -#define REG_ESP ESP -#define REG_EIP EIP -#define REG_EFL EFL -#define REG_TRAPNO TRAPNO -#define REG_ERR ERR -#endif - -void dump_regs(struct ucontext *uc) -{ - printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" - "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" - "EFL=%08x EIP=%08x trapno=%02x err=%08x\n", - uc->uc_mcontext.gregs[REG_EAX], - uc->uc_mcontext.gregs[REG_EBX], - uc->uc_mcontext.gregs[REG_ECX], - uc->uc_mcontext.gregs[REG_EDX], - uc->uc_mcontext.gregs[REG_ESI], - uc->uc_mcontext.gregs[REG_EDI], - uc->uc_mcontext.gregs[REG_EBP], - uc->uc_mcontext.gregs[REG_ESP], - uc->uc_mcontext.gregs[REG_EFL], - uc->uc_mcontext.gregs[REG_EIP], - uc->uc_mcontext.gregs[REG_TRAPNO], - uc->uc_mcontext.gregs[REG_ERR]); -} - -void sig_handler(int sig, siginfo_t *info, void *puc) -{ - struct ucontext *uc = puc; - - printf("%s: si_signo=%d si_errno=%d si_code=%d si_addr=0x%08lx\n", - strsignal(info->si_signo), - info->si_signo, info->si_errno, info->si_code, - (unsigned long)info->si_addr); - dump_regs(uc); - longjmp(jmp_env, 1); -} - -int v1; -int tab[2]; - -int main(int argc, char **argv) -{ - struct sigaction act; - volatile int val; - - act.sa_sigaction = sig_handler; - sigemptyset(&act.sa_mask); - act.sa_flags = SA_SIGINFO; - sigaction(SIGFPE, &act, NULL); - sigaction(SIGILL, &act, NULL); - sigaction(SIGSEGV, &act, NULL); - sigaction(SIGTRAP, &act, NULL); - - /* test division by zero reporting */ - if (setjmp(jmp_env) == 0) { - /* now divide by zero */ - v1 = 0; - v1 = 2 / v1; - } - - /* test illegal instruction reporting */ - if (setjmp(jmp_env) == 0) { - /* now execute an invalid instruction */ - asm volatile("ud2"); - } - - /* test SEGV reporting */ - if (setjmp(jmp_env) == 0) { - /* now store in an invalid address */ - *(char *)0x1234 = 1; - } - - /* test SEGV reporting */ - if (setjmp(jmp_env) == 0) { - /* read from an invalid address */ - v1 = *(char *)0x1234; - } - - printf("segment GPF exception:\n"); - if (setjmp(jmp_env) == 0) { - /* load an invalid segment */ - asm volatile ("movl %0, %%fs" : : "r" ((0x1234 << 3) | 0)); - } - - printf("INT exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("int $0xfd"); - } - - printf("INT3 exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("int3"); - } - - printf("CLI exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("cli"); - } - - printf("STI exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("cli"); - } - - printf("INTO exception:\n"); - if (setjmp(jmp_env) == 0) { - /* overflow exception */ - asm volatile ("addl $1, %0 ; into" : : "r" (0x7fffffff)); - } - - printf("BOUND exception:\n"); - if (setjmp(jmp_env) == 0) { - /* bound exception */ - tab[0] = 1; - tab[1] = 10; - asm volatile ("bound %0, %1" : : "r" (11), "m" (tab)); - } - - printf("OUTB exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("outb %%al, %%dx" : : "d" (0x4321), "a" (0)); - } - - printf("INB exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("inb %%dx, %%al" : "=a" (val) : "d" (0x4321)); - } - - printf("REP OUTSB exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("rep outsb" : : "d" (0x4321), "S" (tab), "c" (1)); - } - - printf("REP INSB exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("rep insb" : : "d" (0x4321), "D" (tab), "c" (1)); - } - - printf("HLT exception:\n"); - if (setjmp(jmp_env) == 0) { - asm volatile ("hlt"); - } - - printf("single step exception:\n"); - val = 0; - if (setjmp(jmp_env) == 0) { - asm volatile ("pushf\n" - "orl $0x00100, (%%esp)\n" - "popf\n" - "movl $0xabcd, %0\n" : "=m" (val) : : "cc", "memory"); - } - printf("val=0x%x\n", val); - -#if 1 - { - int i; - act.sa_handler = alarm_handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - sigaction(SIGALRM, &act, NULL); - alarm(1); - for(i = 0;i < 2; i++) { - sleep(1); - } - } -#endif - return 0; -} |