Cleans up tests/
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 6 Dec 2013 22:20:09 +0000 (14:20 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jan 2014 21:07:51 +0000 (13:07 -0800)
We're making a lot of old tests that we don't need, and they all
bloat the size of the initramfs.  This cuts it from 48MB to 26MB or so,
for me.  Glibc still takes up 13MB.

Part of the reason each test is large (200KB+) is that they all
statically link parlib.

All of the tests still live in an old/ directory.  Feel free to add more
tests, in general.  Anything we'll regularly use can be in the main
tests/ directory.  I'm just tired of building (and copying across the
network) huge kernel images.

You might need to make userclean.

You'll also want to clean out binaries from kern/kfs/bin, since those
won't get automatically cleaned.  To do this, I mv'd busybox out of KFS
temporarily, then did:

$ find kern/kfs/bin -type f -exec rm '{}' \+

(or something similar) to remove the binaries, but not the symlinks for
busybox.  Then I mv'd busybox back.

98 files changed:
tests/Makefile
tests/appender.c [deleted file]
tests/arsc_mt.c [deleted file]
tests/arsc_test.c [deleted file]
tests/badsegment.c [deleted file]
tests/breakpoint.c [deleted file]
tests/buggyhello.c [deleted file]
tests/condvar_test.c [deleted file]
tests/cpp_streams.cc [deleted file]
tests/divzero.c [deleted file]
tests/dtls_test.c [deleted file]
tests/eth_audio.c [deleted file]
tests/evilhello.c [deleted file]
tests/faultread.c [deleted file]
tests/faultreadkernel.c [deleted file]
tests/faultwrite.c [deleted file]
tests/faultwritekernel.c [deleted file]
tests/fork.c [deleted file]
tests/fp_test.c [deleted file]
tests/fpperf.cc [deleted file]
tests/hart_test.c [deleted file]
tests/idle.c [deleted file]
tests/kern_tests.h [deleted file]
tests/manycore_test.c [deleted file]
tests/mproctests.c [deleted file]
tests/msr_cycling_vcores.c [deleted file]
tests/msr_dumb_while.c [deleted file]
tests/msr_get_cores.c [deleted file]
tests/msr_get_singlecore.c [deleted file]
tests/msr_nice_while.c [deleted file]
tests/msr_single_while.c [deleted file]
tests/null.c [deleted file]
tests/old/appender.c [new file with mode: 0644]
tests/old/arsc_mt.c [new file with mode: 0644]
tests/old/arsc_test.c [new file with mode: 0644]
tests/old/badsegment.c [new file with mode: 0644]
tests/old/breakpoint.c [new file with mode: 0644]
tests/old/buggyhello.c [new file with mode: 0644]
tests/old/condvar_test.c [new file with mode: 0644]
tests/old/cpp_streams.cc [new file with mode: 0644]
tests/old/divzero.c [new file with mode: 0644]
tests/old/dtls_test.c [new file with mode: 0644]
tests/old/eth_audio.c [new file with mode: 0644]
tests/old/evilhello.c [new file with mode: 0644]
tests/old/faultread.c [new file with mode: 0644]
tests/old/faultreadkernel.c [new file with mode: 0644]
tests/old/faultwrite.c [new file with mode: 0644]
tests/old/faultwritekernel.c [new file with mode: 0644]
tests/old/fork.c [new file with mode: 0644]
tests/old/fp_test.c [new file with mode: 0644]
tests/old/fpperf.cc [new file with mode: 0644]
tests/old/hart_test.c [new file with mode: 0644]
tests/old/idle.c [new file with mode: 0644]
tests/old/kern_tests.h [new file with mode: 0644]
tests/old/manycore_test.c [new file with mode: 0644]
tests/old/mproctests.c [new file with mode: 0644]
tests/old/msr_cycling_vcores.c [new file with mode: 0644]
tests/old/msr_dumb_while.c [new file with mode: 0644]
tests/old/msr_get_cores.c [new file with mode: 0644]
tests/old/msr_get_singlecore.c [new file with mode: 0644]
tests/old/msr_nice_while.c [new file with mode: 0644]
tests/old/msr_single_while.c [new file with mode: 0644]
tests/old/null.c [new file with mode: 0644]
tests/old/proctests.c [new file with mode: 0644]
tests/old/raise.c [new file with mode: 0644]
tests/old/slab.c [new file with mode: 0644]
tests/old/softint.c [new file with mode: 0644]
tests/old/spawn.c [new file with mode: 0644]
tests/old/syscall.c [new file with mode: 0644]
tests/old/syscall_speed.c [new file with mode: 0644]
tests/old/tcp_test.c [new file with mode: 0644]
tests/old/test_mmap_ipc.c [new file with mode: 0644]
tests/old/test_ucq.c [new file with mode: 0644]
tests/old/testbss.c [new file with mode: 0644]
tests/old/tlstest.c [new file with mode: 0644]
tests/old/tsc_spitter.c [new file with mode: 0644]
tests/old/udp_test.c [new file with mode: 0644]
tests/old/user_tests.h [new file with mode: 0644]
tests/old/vvadd.c [new file with mode: 0644]
tests/openmp/Makefrag
tests/openmp/old/omp_hello.c [new file with mode: 0644]
tests/openmp/omp_hello.c [deleted file]
tests/proctests.c [deleted file]
tests/raise.c [deleted file]
tests/slab.c [deleted file]
tests/softint.c [deleted file]
tests/spawn.c [deleted file]
tests/syscall.c [deleted file]
tests/syscall_speed.c [deleted file]
tests/tcp_test.c [deleted file]
tests/test_mmap_ipc.c [deleted file]
tests/testbss.c [deleted file]
tests/tlstest.c [deleted file]
tests/tsc_spitter.c [deleted file]
tests/ucq.c [deleted file]
tests/udp_test.c [deleted file]
tests/user_tests.h [deleted file]
tests/vvadd.c [deleted file]

index 71b2429..465c2e9 100644 (file)
@@ -10,8 +10,8 @@ TESTS_CXXFLAGS += $(CXXFLAGS_USER) -g
 
 TESTS_LDLIBS := -lpthread -lbenchutil -lm
 
-TESTS_SRCS_C = $(shell ls $(TESTS_DIR)/*.c)
-TESTS_SRCS_CPP = $(shell ls $(TESTS_DIR)/*.cc)
+TESTS_SRCS_C := $(wildcard $(TESTS_DIR)/*.c)
+TESTS_SRCS_CPP := $(wildcard $(TESTS_DIR)/*.cc)
 
 TESTS_LDDEPENDS_C := $(TESTS_DIR)/%.c 
 TESTS_LDDEPENDS_CPP := $(TESTS_DIR)/%.cc
diff --git a/tests/appender.c b/tests/appender.c
deleted file mode 100644 (file)
index 7238817..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdio.h> 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <arch/arch.h>
-#include <unistd.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define WRITE_AMOUNT 4096
-int main(int argc, char *argv[]) 
-{ 
-       int retval;
-       char wbuf[WRITE_AMOUNT];
-       if (argc < 2) {
-               printf("Appends some shit to the end of a text file\n");
-               printf("Usage: appender FILENAME\n");
-               return -1;
-       }
-
-       int fd = open(argv[1], O_RDWR);
-       if (!fd) {
-               printf("Unable to open %s\n", argv[1]);
-               return -1;
-       }
-
-       for (int i = 0; i < WRITE_AMOUNT; i += 4) {
-               wbuf[i + 0] = 'X';
-               wbuf[i + 1] = 'M';
-               wbuf[i + 2] = 'E';
-               wbuf[i + 3] = ' ';
-       }
-       
-       lseek(fd, 0, SEEK_END);
-       retval = write(fd, wbuf, WRITE_AMOUNT);
-       printf("Tried to write %d bytes, got retval: %d\n", WRITE_AMOUNT, retval);
-       return 0;
-}
diff --git a/tests/arsc_mt.c b/tests/arsc_mt.c
deleted file mode 100644 (file)
index 218e545..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifdef CONFIG_ARSC_SERVER
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <vcore.h>
-#include <parlib.h>
-#include <ros/syscall.h>
-#include <arc.h>
-#include <stdio.h>
-
-#define NUM_THREADS 4
-
-pthread_t t1;
-
-async_desc_t desc1;
-
-syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
-                     void (*cleanup_handler)(void*), void* cleanup_data)
-{                                                                                                                     
-       return arc_call(SYS_cputs, s, len);
-}
-
-void *syscall_thread(void* arg)
-{
-       char testme ='a';
-       char buf[20] = {0};
-       sprintf(buf, "%d", (pthread_self()->id % 10) );
-       char tid = buf[0];
-       syscall_desc_t* sysdesc;
-       sysdesc = sys_cputs_async(&tid, 1, NULL, NULL);
-       assert (-1 != waiton_syscall(sysdesc));
-}
-
-int main(int argc, char** argv){
-       int pid = sys_getpid();
-       pthread_t *my_threads = malloc(sizeof(pthread_t) * NUM_THREADS);
-       char testme = 't';
-       printf ("multi thread - init arsc \n");
-       init_arc(&SYS_CHANNEL);
-       for (int i = 0; i < NUM_THREADS ; i++)
-               pthread_create(&my_threads[i], NULL, &syscall_thread, NULL);
-       
-       for (int i = 0; i < NUM_THREADS; i++){
-               pthread_join(my_threads[i], NULL);
-       }
-
-       printf("multi thread - end\n");
-}
-#else
-int main(){};
-#endif
diff --git a/tests/arsc_test.c b/tests/arsc_test.c
deleted file mode 100644 (file)
index 58321fa..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifdef CONFIG_ARSC_SERVER
-#include <parlib.h>
-#include <vcore.h>
-#include <ros/syscall.h>
-#include <arc.h>
-#include <stdio.h>
-
-syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
-                     void (*cleanup_handler)(void*), void* cleanup_data)
-{                                                                                                                     
-    /*// could just hardcode 4 0's, will eventually wrap this marshaller anyway                                         
-       syscall_desc_t* desc;
-    syscall_req_t syscall = {REQ_alloc, cleanup_handler, cleanup_data,
-                                                       SYS_cputs,{(uint32_t)s, len, [2 ... (NUM_SYSCALL_ARGS-1)] 0} };                          
-    syscall.cleanup = cleanup_handler;                                                                                  
-    syscall.data = cleanup_data;
-    async_syscall(&syscall, &desc);
-       */
-       return arc_call(SYS_cputs, s, len);
-}
-
-int main(int argc, char** argv){
-       int pid = sys_getpid();
-       char testme = 't';
-       printf ("single thread - init arsc \n");
-       syscall_desc_t* sysdesc[2];
-       syscall_rsp_t sysrsp;
-       init_arc(&SYS_CHANNEL);
-
-       printf ("single thread - init complete \n");
-       // cprintf_async(&desc1, "Cross-Core call 1, coming from process %08x\n", pid);
-       sysdesc[0] = sys_cputs_async(&testme, 1, NULL, NULL);
-       sysdesc[1] = sys_cputs_async(&testme, 1, NULL, NULL);
-
-       printf ("single thread - call placed \n");
-       //ignore return value
-       assert(-1 != waiton_syscall(sysdesc[0]));
-       assert(-1 != waiton_syscall(sysdesc[1]));
-       printf ("single thread - dummy call \n");       
-}
-
-#else
-int main(){};
-#endif
diff --git a/tests/badsegment.c b/tests/badsegment.c
deleted file mode 100644 (file)
index 6926bf3..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// program to cause a general protection exception
-
-int main(int argc, char** argv)
-{
-       // Try to load the kernel's TSS selector into the DS register.
-       //asm volatile("movw $28,%ax; movw %ax,%ds");
-  
-       // DP: 0x28 == 40
-       #ifdef __i386__
-       asm volatile("movw $40,%ax; movw %ax,%ds");
-       #endif
-       return 0;
-}
-
diff --git a/tests/breakpoint.c b/tests/breakpoint.c
deleted file mode 100644 (file)
index 124bc6c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// program to cause a breakpoint trap
-
-#include <arch/arch.h>
-
-int main(int argc, char** argv)
-{
-       breakpoint();
-       return 0;
-}
-
diff --git a/tests/buggyhello.c b/tests/buggyhello.c
deleted file mode 100644 (file)
index 05232e9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// buggy hello world -- unmapped pointer passed to kernel
-// kernel should destroy user process in response
-
-#include <parlib.h>
-
-int main(int argc, char** argv)
-{
-       sys_cputs((char*SAFE)TC(1), 1);
-       return 0;
-}
-
diff --git a/tests/condvar_test.c b/tests/condvar_test.c
deleted file mode 100644 (file)
index 725a501..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <stdio.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-/* OS dependent #incs */
-#include <parlib.h>
-#include <vcore.h>
-#include <timing.h>
-
-#define MAX_NR_TEST_THREADS 1000
-
-pthread_t my_threads[MAX_NR_TEST_THREADS];
-void *my_retvals[MAX_NR_TEST_THREADS];
-
-
-/* Funcs and global vars for test_cv() */
-pthread_cond_t local_cv;
-pthread_cond_t *cv = &local_cv;
-pthread_mutex_t local_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t *pth_m = &local_mutex;
-
-atomic_t counter;
-volatile bool state = FALSE;           /* for test 3 */
-
-void *__test_pthread_cond_signal(void *arg)
-{
-       if (atomic_read(&counter) % 4)
-               pthread_cond_signal(cv);
-       else
-               pthread_cond_broadcast(cv);
-       atomic_dec(&counter);
-}
-
-void *__test_pthread_cond_waiter(void *arg)
-{
-       pthread_mutex_lock(pth_m);
-       /* check state, etc */
-       pthread_cond_wait(cv, pth_m);
-       pthread_mutex_unlock(pth_m);
-       atomic_dec(&counter);
-}
-
-void *__test_pthread_cond_waiter_t3(void *arg)
-{
-       udelay((long)arg);
-       /* if state == false, we haven't seen the signal yet */
-       pthread_mutex_lock(pth_m);
-       printd("Came in, saw state %d\n", state);
-       while (!state) {
-               cpu_relax();
-               pthread_cond_wait(cv, pth_m);   /* unlocks and relocks */
-       }
-       pthread_mutex_unlock(pth_m);
-       /* Make sure we are done, tell the controller we are done */
-       cmb();
-       assert(state);
-       atomic_dec(&counter);
-}
-
-int main(void)
-{
-       int nr_msgs;
-       pthread_lib_init();
-       pthread_cond_init(cv, 0);
-       pthread_mutex_init(pth_m, 0);
-
-       /* Test 0: signal without waiting */
-       pthread_cond_broadcast(cv);
-       pthread_cond_signal(cv);
-       printf("test_cv: signal without waiting complete\n");
-
-       /* Test 1: single / minimal shit */
-       nr_msgs = max_vcores() - 1;
-       atomic_init(&counter, nr_msgs);
-       for (int i = 0; i < nr_msgs; i++) {
-               if (pthread_create(&my_threads[i], NULL, &__test_pthread_cond_waiter,
-                   NULL))
-                       perror("pth_create failed");
-       }
-       udelay(1000000);
-       pthread_cond_signal(cv);
-       /* wait for one to make it */
-       while (atomic_read(&counter) != nr_msgs - 1)
-               pthread_yield();
-       printf("test_cv: single signal complete\n");
-       pthread_cond_broadcast(cv);
-       for (int i = 0; i < nr_msgs; i++)
-               pthread_join(my_threads[i], &my_retvals[i]);
-       printf("test_cv: broadcast signal complete\n");
-
-       /* Test 2: shitloads of waiters and signalers */
-       nr_msgs = MAX_NR_TEST_THREADS;
-       atomic_init(&counter, nr_msgs);
-       for (int i = 0; i < nr_msgs; i++) {
-               if (i % 5) {
-                       if (pthread_create(&my_threads[i], NULL,
-                           &__test_pthread_cond_waiter, NULL))
-                               perror("pth_create failed");
-               } else {
-                       if (pthread_create(&my_threads[i], NULL,
-                           &__test_pthread_cond_signal, NULL))
-                               perror("pth_create failed");
-               }
-       }
-       pthread_yield();
-       while (atomic_read(&counter)) {
-               cpu_relax();
-               pthread_cond_broadcast(cv);
-               pthread_yield();
-       }
-       for (int i = 0; i < nr_msgs; i++)
-               pthread_join(my_threads[i], &my_retvals[i]);
-       printf("test_cv: massive message storm complete\n");
-
-       /* Test 3: basic one signaller, one receiver.  we want to vary the amount of
-        * time the sender and receiver delays, starting with (1ms, 0ms) and ending
-        * with (0ms, 1ms).  At each extreme, such as with the sender waiting 1ms,
-        * the receiver/waiter should hit the "check and wait" point well before the
-        * sender/signaller hits the "change state and signal" point.
-        *
-        * Need to make sure we are running in parallel here.  Temp turned off the
-        * 2LSs VC management and got up to 2 VC.  Assuming no preemption. */
-       pthread_can_vcore_request(FALSE);       /* 2LS won't manage vcores */
-       while (num_vcores() < 2)
-               vcore_request(1);
-       for (long i = 0; i < 1000; i++) {
-               for (int j = 0; j < 10; j++) {  /* some extra chances at each point */
-                       state = FALSE;
-                       /* client waits for i usec */
-                       if (pthread_create(&my_threads[0], NULL,
-                           &__test_pthread_cond_waiter_t3, (void*)i))
-                               perror("pth_create failed");
-                       cmb();
-                       udelay(1000 - i);       /* senders wait time: 1000..0 */
-                       /* Need to lock the mutex when touching state and signalling about
-                        * that state (atomically touch and signal).  Thanks pthreads, for
-                        * mandating a cond_signal that doesn't require locking. */
-                       pthread_mutex_lock(pth_m);
-                       state = TRUE;
-                       pthread_cond_signal(cv);
-                       pthread_mutex_unlock(pth_m);
-                       /* they might not have run at all yet (in which case they lost the
-                        * race and don't need the signal).  but we need to wait til they're
-                        * done */
-                       pthread_join(my_threads[0], my_retvals[0]);
-               }
-       }
-       pthread_can_vcore_request(TRUE);        /* 2LS controls VCs again */
-       printf("test_cv: single sender/receiver complete\n");
-}
diff --git a/tests/cpp_streams.cc b/tests/cpp_streams.cc
deleted file mode 100644 (file)
index 1e9f30a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <errno.h>
-
-using namespace std;
-
-int main() {
-       string line;
-       ifstream myfile;
-       errno = 0;
-       myfile.open("hello.txt", ifstream::in);
-       if (errno)
-               perror("Unable to open (hello.txt):");
-       if (myfile.is_open()) {
-               while (myfile.good()) {
-                 getline(myfile, line);
-                 cout << line << endl;
-               }
-               myfile.close();
-               cout << "Stream test passed" << endl;
-       } else {
-               cout << "Unable to open file"; 
-       }
-       return 0;
-}
diff --git a/tests/divzero.c b/tests/divzero.c
deleted file mode 100644 (file)
index 59dbf18..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// buggy program - causes a divide by zero exception
-
-#include <stdio.h>
-
-int zero;
-
-int main(int argc, char** argv)
-{
-       printf("1/0 is %08x!\n", 1/zero);
-       return 0;
-}
-
diff --git a/tests/dtls_test.c b/tests/dtls_test.c
deleted file mode 100644 (file)
index 1087fb2..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdio.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-/* OS dependent #incs */
-#include <parlib.h>
-
-#define NR_TEST_THREADS 10
-#define NUM_PTHREAD_KEYS 10
-pthread_t my_threads[NR_TEST_THREADS];
-void *my_retvals[NR_TEST_THREADS];
-pthread_key_t pthread_keys[NUM_PTHREAD_KEYS];
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-void *thread(void* arg)
-{      
-  long *dtls_value[NUM_PTHREAD_KEYS];
-  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
-    dtls_value[i] = malloc(sizeof(long));
-    *dtls_value[i] = (long)pthread_self() + i;
-    pthread_setspecific(pthread_keys[i], dtls_value[i]);
-  }
-
-  pthread_mutex_lock(&mutex);
-  long self = (long)pthread_self();
-  printf("In pthread %p (%ld)\n", (void*)self, self);
-  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
-    long *value = pthread_getspecific(pthread_keys[i]);
-    printf("  dtls_value[%d] = %ld\n", i, *value);
-  }
-  pthread_mutex_unlock(&mutex);
-
-  return (void*)(self);
-}
-
-static void dtls_dtor(void *dtls)
-{
-  pthread_mutex_lock(&mutex);
-  printf("Phread %p freeing dtls %p.\n", pthread_self(), dtls);
-  free(dtls);
-  pthread_mutex_unlock(&mutex);
-}
-
-int main(int argc, char** argv) 
-{
-  printf("Starting dtls test.\n");
-  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
-    pthread_key_create(&pthread_keys[i], dtls_dtor);
-  }
-  for (int i = 0; i < NR_TEST_THREADS; i++) {
-       if (pthread_create(&my_threads[i], NULL, &thread, NULL))
-               perror("pth_create failed");
-  }
-  for (int i = 0; i < NR_TEST_THREADS; i++) {
-       pthread_join(my_threads[i], &my_retvals[i]);
-  }
-  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
-    pthread_key_delete(pthread_keys[i]);
-  }
-  printf("Test complete!\n");
-} 
diff --git a/tests/eth_audio.c b/tests/eth_audio.c
deleted file mode 100644 (file)
index 2c0fc23..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <ros/resource.h>
-#include <ros/procdata.h>
-#include <ros/event.h>
-#include <ros/bcq.h>
-#include <parlib.h>
-#include <vcore.h>
-
-#include <stdio.h> 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <arch/arch.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <timing.h>
-#include <assert.h>
-#include <event.h>
-#include <uthread.h>
-
-void *core0_tls = 0;
-void *in_buf, *out_buf;
-
-/* Test program for the audio device.  mmap()s the stuff, sets up a notif
- * handler, and switches to multi_mode.
- *
- * Note: this has a lot of mhello-like MCP infrastructure.  When Lithe is
- * working, you won't need any of this.  Just the mmap stuff and the notif
- * handler.  Stuff specific to the ethernet audio device is marked ETH_AUD. */
-int main() 
-{ 
-       int retval;
-       int in_fd, out_fd;
-       /* ETHAUD mmap the input and output buffers */
-       in_fd = open("/dev/eth_audio_in", O_RDONLY);
-       out_fd = open("/dev/eth_audio_out", O_RDWR);
-       assert(in_fd != -1);
-       assert(out_fd != -1);
-       in_buf = mmap(0, PGSIZE, PROT_READ, 0, in_fd, 0);
-       if (in_buf == MAP_FAILED) {
-               int err = errno;
-               perror("Can't mmap the input buf:");
-       }
-       out_buf = mmap(0, PGSIZE, PROT_READ | PROT_WRITE, MAP_POPULATE, out_fd, 0);
-       if (out_buf == MAP_FAILED) {
-               int err = errno;
-               perror("Can't mmap the output buf:");
-       }
-       //strncpy(out_buf, "Nanwan loves you!\n", 19);
-
-/* begin: stuff userspace needs to do before switching to multi-mode */
-       vcore_init();
-
-       /* ETHAUD Turn on Free apple pie (which is the network packet) */
-       enable_kevent(EV_FREE_APPLE_PIE, 0, EVENT_IPI);
-
-       /* Need to save this somewhere that you can find it again when restarting
-        * core0 */
-       core0_tls = get_tls_desc(0);
-       /* Need to save our floating point state somewhere (like in the
-        * user_thread_tcb so it can be restarted too */
-
-/* end: stuff userspace needs to do before switching to multi-mode */
-       /* ETHAUD */
-       /* Switch into _M mode */
-       retval = vcore_request(1);
-
-       /* Stay alive for a minute (will take interrupts) */
-       udelay(60000000);
-
-       printf("Eth aud, finishing up!\n");
-       /* Need to do unmap it, due to some limitations in the kernel */
-       munmap(in_buf, PGSIZE);
-       munmap(out_buf, PGSIZE);
-       close(in_fd);
-       close(out_fd);
-}
-
-/* ETHAUD, with some debugging commands... */
-void process_packet(void)
-{
-       //printf("Received a packet!\n");
-       //memset(out_buf, 0, PGSIZE);
-       memcpy(out_buf, in_buf, 1280);  /* size of the payload. */
-       memset(out_buf + 1280, 0, 4);   /* 4 bytes of control info. */
-       //printf("contents of out_buf %s\n", out_buf);
-}
-
-void vcore_entry(void)
-{
-       uint32_t vcoreid = vcore_id();
-       static bool first_time = TRUE;
-
-       printf("GIANT WARNING: this is ancient shit\n");
-/* begin: stuff userspace needs to do to handle events/notifications */
-
-       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
-       struct preempt_data *vcpd;
-       vcpd = &__procdata.vcore_preempt_data[vcoreid];
-       
-       /* Ghetto way to get just an event number */
-       unsigned int ev_type = get_event_type(&vcpd->ev_mbox_public);
-
-       /* ETHAUD app: process the packet if we got a notif */
-       if (ev_type == EV_FREE_APPLE_PIE)
-               process_packet();
-
-       if (vc->preempt_pending) {
-               printf("Oh crap, vcore %d is being preempted!  Yielding\n", vcoreid);
-               sys_yield(TRUE);
-               printf("After yield on vcore %d. I wasn't being preempted.\n", vcoreid);
-       }
-               
-       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
-        * set the appropriate TLS.  On x86, this will involve changing the LDT
-        * entry for this vcore to point to the TCB of the new user-thread. */
-       if (vcoreid == 0) {
-               handle_events(vcoreid);
-               set_tls_desc(core0_tls, 0);
-               assert(__vcoreid == 0); /* in case anyone uses this */
-               /* Load silly state (Floating point) too */
-               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
-               printf("should never see me!");
-       }       
-       /* unmask notifications once you can let go of the uthread_ctx and it is
-        * okay to clobber the transition stack.
-        * Check Documentation/processes.txt: 4.2.4.  In real code, you should be
-        * popping the tf of whatever user process you want (get off the x-stack) */
-       vcpd->notif_disabled = FALSE;
-       
-/* end: stuff userspace needs to do to handle notifications */
-       /* The other vcores will hit here. */
-       while (1)
-               cpu_relax();
-}
diff --git a/tests/evilhello.c b/tests/evilhello.c
deleted file mode 100644 (file)
index 1edac84..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// evil hello world -- kernel pointer passed to kernel
-// kernel should destroy user process in response
-
-#include <parlib.h>
-
-int main(int argc, char** argv)
-{
-       while(1);
-       // try to print the kernel entry point as a string!  mua ha ha!
-       sys_cputs((char*SAFE)TC(0xc0100020), 100);
-       return 0;
-}
-
diff --git a/tests/faultread.c b/tests/faultread.c
deleted file mode 100644 (file)
index 3cf8a3f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// buggy program - faults with a read from location zero
-
-#include <stdio.h>
-
-int main(int argc, char** argv)
-{ 
-       printf("I read %08x from location 0!\n", *(unsigned*)0);
-       return 0;
-}
-
diff --git a/tests/faultreadkernel.c b/tests/faultreadkernel.c
deleted file mode 100644 (file)
index cef359f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// buggy program - faults with a read from kernel space
-
-#include <stdio.h>
-
-int main(int argc, char** argv)
-{
-       printf("I read %08x from location 0xf0100000!\n", *(unsigned*)0xf0100000);
-       return 0;
-}
-
diff --git a/tests/faultwrite.c b/tests/faultwrite.c
deleted file mode 100644 (file)
index 05b1861..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// buggy program - faults with a write to location zero
-
-int main(int argc, char** argv)
-{
-       *(unsigned*)0 = 0;
-       return 0;
-}
-
diff --git a/tests/faultwritekernel.c b/tests/faultwritekernel.c
deleted file mode 100644 (file)
index 8b07449..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// buggy program - faults with a write to a kernel location
-
-
-int main(int argc, char** argv)
-{ 
-       *(unsigned*)0xf0100000 = 0;
-       return 0;
-}
-
diff --git a/tests/fork.c b/tests/fork.c
deleted file mode 100644 (file)
index b7efa42..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int main(int argc, char** argv)
-{
-       int status;
-       pid_t pid = 0;
-       pid = fork();
-       if (pid) {
-               printf("Hello world from parent!!\n");
-               waitpid(pid, &status, 0);
-       } else {
-               printf("Hello world from child!!\n");
-               printf("Child trying to exec Hello...\n");
-               execv("/bin/hello", argv);
-       }
-       return 0;
-}
diff --git a/tests/fp_test.c b/tests/fp_test.c
deleted file mode 100644 (file)
index eaf8fb2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdio.h>
-
-int main(int argc, char** argv) 
-{
-       volatile float x = 2.5;
-       volatile float y = 5.0;
-       volatile float var = x*y;
-       printf("value decimal: %d\n", (int)var);
-//     printf("value floating: %f\n", var);
-
-//     int x = 25;
-//     int y = 50;
-//     int var = x*y;
-//     printf("value: %d\n", var);
-} 
diff --git a/tests/fpperf.cc b/tests/fpperf.cc
deleted file mode 100644 (file)
index f0b3dc6..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Chunk of code from stage 6 of fluidanimate, running on its own in a single
- * process, meant to run on either linux or akaros (check the ifdef below). */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <float.h>
-#include <math.h>
-#include <cstdlib>
-#include <cstring>
-#include <algorithm>
-#include <sys/time.h>
-#include <pthread.h>
-
-typedef float fptype;
-
-class Vec3
-{
-public:
-  fptype x, y, z;
-
-  Vec3() {}
-  Vec3(fptype _x, fptype _y, fptype _z) : x(_x), y(_y), z(_z) {}
-
-  fptype  GetLengthSq() const         { return x*x + y*y + z*z; }
-  fptype  GetLength() const           { return sqrtf(GetLengthSq()); }
-  Vec3 &  Normalize()                 { return *this /= GetLength(); }
-
-  bool    operator == (Vec3 const &v) { return (x == v.x) && (y == v.y) && (z += v.z); }
-  Vec3 &  operator += (Vec3 const &v) { x += v.x;  y += v.y; z += v.z; return *this; }
-  Vec3 &  operator -= (Vec3 const &v) { x -= v.x;  y -= v.y; z -= v.z; return *this; }
-  Vec3 &  operator *= (fptype s)      { x *= s;  y *= s; z *= s; return *this; }
-  Vec3 &  operator /= (fptype s)      { fptype tmp = 1.f/s; x *= tmp;  y *= tmp; z *= tmp; return *this; }
-
-  Vec3    operator + (Vec3 const &v) const    { return Vec3(x+v.x, y+v.y, z+v.z); }
-  Vec3    operator + (fptype const &f) const  { return Vec3(x+f, y+f, z+f); }
-  Vec3    operator - () const                 { return Vec3(-x, -y, -z); }
-  Vec3    operator - (Vec3 const &v) const    { return Vec3(x-v.x, y-v.y, z-v.z); }
-  Vec3    operator * (fptype s) const         { return Vec3(x*s, y*s, z*s); }
-  Vec3    operator / (fptype s) const         { fptype tmp = 1.f/s; return Vec3(x*tmp, y*tmp, z*tmp); }
-
-  fptype  operator * (Vec3 const &v) const    { return x*v.x + y*v.y + z*v.z; }
-};
-
-float rand_f1 = 3.14;
-float rand_f2 = 6.282222;
-float rand_f3 = 443.38383;
-float rand_f4;
-float rand_f5;
-static const fptype doubleRestDensity = 2000.0;
-static const fptype viscosity = 0.4;
-
-static const Vec3 rand_v3_1(0.1, -9.8, 30.0);
-static const Vec3 rand_v3_2(0.2, -90.8, 0.5);
-static const Vec3 rand_v3_3(7.3, -444.8, 8.0);
-static const Vec3 rand_v3_4(8.4, -99.8, 0.8);
-
-Vec3 output(0, 0, 0);
-
-int main(int argc, char **argv)
-{
-       struct timeval start_tv = {0};
-       struct timeval end_tv = {0};
-       uint64_t usec_diff;
-       if (argc < 3) {
-               printf("Need 2 args\n");
-               exit(-1);
-       }
-
-       /* Disable this if you want to compile for linux with the i686-ros-g++ */
-       #if 1
-       # ifdef __ros__
-       if (argc == 4) {
-               pthread_can_vcore_request(FALSE);
-               pthread_lib_init();                             
-               printf("Vcore %d mapped to pcore %d\n", 0, __procinfo.vcoremap[0].pcoreid);
-       }
-       # endif
-       #endif
-
-       rand_f4 = (float)atoi(argv[1]);
-       rand_f5 = (float)atoi(argv[2]);
-       if (gettimeofday(&start_tv, 0))
-               perror("Start time error...");
-       for (int i = 0; i < 300000000; i++) {
-       
-               Vec3 disp = rand_v3_1 - rand_v3_2 * rand_f5;
-               fptype distSq = disp.GetLengthSq();
-               fptype dist = sqrtf(std::max(distSq, (fptype)1e-12));
-               fptype hmr = rand_f1 - dist;
-               
-               Vec3 acc = disp * rand_f2 * (hmr*hmr/dist)
-                          * (rand_f3 + rand_f4 + rand_f5 - doubleRestDensity);
-               acc += (rand_v3_3 - rand_v3_4 * rand_f5) * viscosity * hmr;
-               acc /= rand_f5 * rand_f1;
-               
-               output += acc;
-       }
-       float ret = output.GetLengthSq();
-       if (gettimeofday(&end_tv, 0))
-               perror("End time error...");
-       usec_diff = (end_tv.tv_sec - start_tv.tv_sec) * 1000000 +
-                   (end_tv.tv_usec - start_tv.tv_usec);
-       printf("%f, took %.3f sec\n", ret, (float)usec_diff / 1000000);
-       return 0;
-}
diff --git a/tests/hart_test.c b/tests/hart_test.c
deleted file mode 100644 (file)
index 51fb0d4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(int argc, char** argv) 
-{
-       printf("Goodbye cruel world!!\n");
-} 
diff --git a/tests/idle.c b/tests/idle.c
deleted file mode 100644 (file)
index 7570069..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <parlib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/* This will keep a core from spinning forever, but will also allow it to still
- * schedule() and run _S processes.  arg1 is the number of loops (0 for
- * forever), and arg2 is how many usec to wait per loop. */
-int main(int argc, char** argv)
-{
-       unsigned long nr_loops = 1;                     /* default, 1 loop */
-       unsigned long timeout = 5000000;        /* default, 5 sec */
-       int i = 0;
-       if (argc > 1)
-               nr_loops = strtol(argv[1], 0, 10);
-       if (argc > 2)
-               timeout = strtol(argv[2], 0, 10);
-       printf("Idling for %d usec for %d loops\n", timeout, nr_loops);
-       while (!nr_loops || i++ < nr_loops) {
-               sys_halt_core(timeout);
-               sys_yield(0);
-       }
-       return 0;
-}
diff --git a/tests/kern_tests.h b/tests/kern_tests.h
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/manycore_test.c b/tests/manycore_test.c
deleted file mode 100644 (file)
index 09ea55b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-#include <vcore.h>
-#include <parlib.h>
-#include <mcs.h>
-#include <uthread.h>
-
-mcs_barrier_t b;
-
-void do_work_son(int vcoreid)
-{
-       int pcoreid = sys_getpcoreid();
-       int pid = sys_getpid();
-       printf("Hello! My Process ID: %d My VCoreID: %d My CPU: %d\n", pid, vcoreid,
-              pcoreid);
-       mcs_barrier_wait(&b,vcoreid);
-}
-
-void vcore_entry()
-{
-       assert(vcore_id() > 0);
-       do_work_son(vcore_id());
-}
-
-int main(int argc, char** argv)
-{
-       assert(vcore_id() == 0);
-       mcs_barrier_init(&b,max_vcores());
-       vcore_request(max_vcores()-1);
-       do_work_son(0);
-       return 0;
-}
diff --git a/tests/mproctests.c b/tests/mproctests.c
deleted file mode 100644 (file)
index b6f231a..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <arch/arch.h>
-#include <parlib.h>
-#include <rassert.h>
-#include <stdlib.h>
-#include <vcore.h>
-#include <ros/mman.h>
-#include <ros/resource.h>
-#include <stdio.h>
-#include <timing.h>
-#include <uthread.h>
-
-#define TEST_MMAP                                       1
-#define TEST_ONE_CORE                           2
-#define TEST_ASK_FOR_TOO_MANY_CORES     3
-#define TEST_INCREMENTAL_CHANGES        4
-#define TEST_YIELD_OUT_OF_ORDER                 5
-#define TEST_YIELD_0_OUT_OF_ORDER       6
-#define TEST_YIELD_ALL               7
-#define TEST_SWITCH_TO_RUNNABLE_S       8
-#define TEST_CRAZY_YIELDS                       9
-#define TEST_CONCURRENT_SYSCALLS       10
-
-int test = TEST_SWITCH_TO_RUNNABLE_S;
-
-static void global_tests(uint32_t vcoreid);
-
-int main(int argc, char** argv)
-{
-       uint32_t vcoreid;
-       int retval;
-       vcore_init();
-
-       if ((vcoreid = vcore_id())) {
-               printf("Should never see me! (from vcore %d)\n", vcoreid);
-       } else { // core 0
-               printf("Hello from else vcore 0\n");
-               printf("Multi-Goodbye, world, from PID: %d!\n", sys_getpid());
-               switch (test) {
-                       case TEST_MMAP:
-                               printf("Testing MMAP\n");
-                               void *CT(8*PGSIZE) addr;
-                               addr = sys_mmap((void*SNT)USTACKTOP - 20*PGSIZE, 8*PGSIZE, 3,
-                                               MAP_FIXED | MAP_ANONYMOUS, -1, 0);
-                               printf("got addr = 0x%08x\n", addr);
-                               *(int*)addr = 0xdeadbeef;
-                               *(int*)(addr + 3*PGSIZE) = 0xcafebabe;
-                               // these should work
-                               printf("reading addr: 0x%08x\n", *(int*)addr);
-                               printf("reading addr+3pg: 0x%08x\n", *(int*)(addr + 3*PGSIZE));
-                               // this should fault
-                               printf("Should page fault and die now.\n");
-                               { TRUSTEDBLOCK
-                               *(int*)(addr - 3*PGSIZE) = 0xdeadbeef;
-                               }
-                               printf("Should not see me!!!!!!!!!!!!!!!!!!\n");
-                               while(1);
-                       case TEST_ONE_CORE:
-                               retval = vcore_request(1);
-                               printf("One core test's core0's retval: %d\n", retval);
-                               printf("Check to see it's on a worker core.\n");
-                               while(1);
-                       case TEST_ASK_FOR_TOO_MANY_CORES:
-                               retval = vcore_request(12);
-                               printf("Asked for too many, retval: %d\n", retval);
-                               return 0;
-                       case TEST_INCREMENTAL_CHANGES:
-                               retval = vcore_request(4);
-                               break;
-                       default:
-                               retval = vcore_request(5);
-               }
-               if (retval)
-                       panic("failed to allocate cores!");
-               printf("Should see me if you want to relocate core0's context "
-                       "when moving from RUNNING_S\n");
-       }
-
-       // vcore0 only below here
-       switch (test) {
-               case TEST_YIELD_OUT_OF_ORDER:
-                       udelay(10000000);
-                       printf("Core 2 should have yielded, asking for another\n");
-                       retval = vcore_request(5);
-                       break;
-               case TEST_YIELD_0_OUT_OF_ORDER:
-                       udelay(5000000);
-                       printf("Core %d yielding\n", vcoreid);
-                       sys_yield(0);
-                       printf("Core 0 came back where it left off in RUNNING_M!!!\n");
-                       break;
-       }
-       global_tests(vcoreid);
-       printf("Vcore %d Done!\n", vcoreid);
-       while (1);
-       return 0;
-}
-
-void vcore_entry(void)
-{
-       uint32_t vcoreid;
-       static int first_time = 1; // used by vcore2
-       int retval;
-
-       vcoreid = vcore_id();
-       printf("Hello from vcore_entry in vcore %d\n", vcoreid);
-
-       if ((vcoreid == 2) && first_time) {
-               first_time = 0;
-               switch (test) {
-                       case TEST_INCREMENTAL_CHANGES:
-                               // Testing asking for less than we already have
-                               udelay(1000000);
-                               printf("Asking for too few:\n");
-                               retval = vcore_request(2);
-                               printf("Should be -EINVAL(7): %d\n", retval);
-                               // Testing getting more while running
-                               printf("Asking for more while running:\n");
-                               udelay(1000000);
-                               retval = vcore_request(5);
-                               printf("core2's retval: %d\n", retval);
-                               break;
-                       case TEST_YIELD_OUT_OF_ORDER:
-                               printf("Core %d yielding\n", vcoreid);
-                               sys_yield(0);
-                               break;
-                       case TEST_YIELD_0_OUT_OF_ORDER:
-                               udelay(7500000);
-                               printf("Core 0 should have yielded, asking for another\n");
-                               retval = vcore_request(5);
-               }
-       }
-       global_tests(vcoreid);
-       printf("Vcore %d Done!\n", vcoreid);
-}
-
-static void global_tests(uint32_t vcoreid)
-{
-       int retval;
-       switch (test) {
-               case TEST_YIELD_ALL:
-                       printf("Core %d yielding\n", vcoreid);
-                       sys_yield(0);
-                       // should be RUNNABLE_M now, amt_wanted == 1
-                       while(1);
-               case TEST_SWITCH_TO_RUNNABLE_S:
-                       if (vcoreid == 2) {
-                               printf("Core %d trying to request 0/ switch to _S\n", vcoreid);
-                               udelay(3000000);
-                               retval = vcore_request(0);
-                               // will only see this if we are scheduled()
-                               printf("Core %d back up! (retval:%d)\n", vcoreid, retval);
-                               printf("And exiting\n");
-                               exit(0);
-                       } 
-                       while(1);
-               case TEST_CRAZY_YIELDS:
-                       udelay(300000*vcoreid);
-                       vcore_request(5);
-                       sys_yield(0);
-                       printf("should  never see me, unless you slip into *_S\n");
-                       break;
-               case TEST_CONCURRENT_SYSCALLS:
-                       for (int i = 0; i < 10; i++) {
-                               for (int j = 0; j < 100; j++)
-                                       sys_null();
-                               printf("Hello from vcore %d, iteration %d\n", vcoreid, i);
-                       }
-                       break;
-       }
-}
diff --git a/tests/msr_cycling_vcores.c b/tests/msr_cycling_vcores.c
deleted file mode 100644 (file)
index 2713719..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* tests/msr_cycling_vcores.c
- *
- * This requests the max_vcores in the system, waits a bit, then gives them
- * back, looping forever.  We can't give up all vcores, based on the current
- * kernel, so we hold on to vcore0 to do the thinking. */
-
-#include <ros/resource.h>
-#include <parlib.h>
-#include <stdio.h>
-#include <vcore.h>
-#include <timing.h>
-#include <mcs.h>
-#include <uthread.h>
-
-mcs_barrier_t b;
-uint64_t begin = 0, end = 0;
-
-int main(int argc, char** argv)
-{
-       printf("Good chance this doesn't work anymore!\n");
-       mcs_barrier_init(&b, max_vcores());
-
-       vcore_request(max_vcores());
-       printf("We're screwed!\n");
-
-       /* should never make it here */
-       return -1;
-}
-
-void vcore_entry(void)
-{
-       uint32_t vcoreid = vcore_id();
-
-       if (vcoreid) {
-               mcs_barrier_wait(&b, vcoreid);
-               udelay(5000000);
-               if (vcoreid == 1)
-                       printf("Proc %d's vcores are yielding\n", getpid());
-               sys_yield(0);
-       } else {
-               /* trip the barrier here, all future times are in the loop */
-               mcs_barrier_wait(&b, vcoreid);
-               while (1) {
-                       udelay(15000000);
-                       printf("Proc %d requesting its cores again\n", getpid());
-                       begin = read_tsc();
-                       vcore_request(max_vcores() - 1); /* since we already have 1 */
-                       mcs_barrier_wait(&b, vcoreid);
-                       end = read_tsc();
-                       printf("Took %llu usec (%llu nsec) to get my yielded cores back.\n",
-                              udiff(begin, end), ndiff(begin, end));
-                       printf("[T]:010:%llu:%llu\n",
-                              udiff(begin, end), ndiff(begin, end));
-               }
-       }
-       printf("We're screwed!\n");
-       exit(-1);
-}
diff --git a/tests/msr_dumb_while.c b/tests/msr_dumb_while.c
deleted file mode 100644 (file)
index 0f965b5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* tests/msr_dumb_while.c
- *
- * This requests the max_vcores in the system, then just dumbly while loops.
- * If you send it an NE_ALARM, it'll print its TSC. */
-
-#include <stdio.h>
-#include <vcore.h>
-#include <arch/arch.h>
-#include <event.h>
-#include <uthread.h>
-
-int main(int argc, char** argv)
-{
-       /* Get EV_ALARM on vcore 1, with IPI. */
-       enable_kevent(EV_ALARM, 1, EVENT_IPI | EVENT_VCORE_PRIVATE);
-
-       vcore_request(max_vcores());
-
-       /* should never make it here */
-       return -1;
-}
-
-void vcore_entry(void)
-{
-       struct preempt_data *vcpd = &__procdata.vcore_preempt_data[0];
-       vcpd->notif_disabled = FALSE;
-
-       unsigned int ev_type = get_event_type(&vcpd->ev_mbox_private);
-       if (ev_type == EV_ALARM)
-               printf("[T]:009:E:%llu\n", read_tsc());
-       while(1);
-}
-
diff --git a/tests/msr_get_cores.c b/tests/msr_get_cores.c
deleted file mode 100644 (file)
index 6784dd2..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* tests/msr_get_cores.c
- *
- * This measures the time it takes to request and receive the max_vcores() in
- * the system.  The clock starts before vcore_request(), which includes the time
- * it takes to allocate transition stacks and TLS.  The clock stops after
- * barriering in vcore_entry(), while vcore0 gets restarted and barriers.  You
- * really want to restart vcore0's context so it releases the lock in
- * vcore_request().
- *
- * This will measure both the hot and cold times, with the hot times not needing
- * to have stacks mmaped and other things. */
-
-
-#include <parlib.h>
-#include <ros/mman.h>
-#include <ros/resource.h>
-#include <ros/procdata.h>
-#include <ros/bcq.h>
-#include <arch/arch.h>
-#include <stdio.h>
-#include <vcore.h>
-#include <mcs.h>
-#include <timing.h>
-#include <rassert.h>
-#include <uthread.h>
-#include <event.h>
-
-mcs_barrier_t b;
-
-void *core0_tls = 0;
-uint64_t begin = 0, end = 0;
-
-int main(int argc, char** argv)
-{
-       uint32_t vcoreid = vcore_id();
-       int retval = 0;
-
-       mcs_barrier_init(&b, max_vcores());
-
-/* begin: stuff userspace needs to do before switching to multi-mode */
-       vcore_init();
-       #if 0
-       /* tell the kernel where and how we want to receive notifications */
-       struct notif_method *nm;
-       for (int i = 0; i < MAX_NR_NOTIF; i++) {
-               nm = &__procdata.notif_methods[i];
-               nm->flags |= NOTIF_WANTED | NOTIF_MSG | NOTIF_IPI;
-               nm->vcoreid = i % 2; // vcore0 or 1, keepin' it fresh.
-       }
-       #endif
-       /* Need to save this somewhere that you can find it again when restarting
-        * core0 */
-       core0_tls = get_tls_desc(0);
-       /* Need to save our floating point state somewhere (like in the
-        * user_thread_tcb so it can be restarted too */
-/* end: stuff userspace needs to do before switching to multi-mode */
-
-       begin = read_tsc();
-       retval = vcore_request(max_vcores());
-       if (retval)
-               printf("Fucked!\n");
-       mcs_barrier_wait(&b, vcoreid);
-       end = read_tsc();
-
-       printf("Took %llu usec (%llu nsec) to receive %d cores (cold).\n",
-              udiff(begin, end), ndiff(begin, end), max_vcores());
-       printf("[T]:001:%llu:%llu:%d:C.\n",
-              udiff(begin, end), ndiff(begin, end), max_vcores());
-       udelay(5000000);
-       begin = read_tsc();
-       retval = vcore_request(max_vcores() - 1);
-       if (retval)
-               printf("Fucked!\n");
-       mcs_barrier_wait(&b, vcoreid);
-       end = read_tsc();
-       printf("Took %llu usec (%llu nsec) to receive %d cores (warm).\n",
-              udiff(begin, end), ndiff(begin, end), max_vcores());
-       printf("[T]:001:%llu:%llu:%d:W.\n",
-              udiff(begin, end), ndiff(begin, end), max_vcores());
-
-       return 0;
-}
-
-void vcore_entry(void)
-{
-       uint32_t vcoreid = vcore_id();
-
-/* begin: stuff userspace needs to do to handle notifications */
-       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
-       struct preempt_data *vcpd;
-       vcpd = &__procdata.vcore_preempt_data[vcoreid];
-       
-       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
-        * set the appropriate TLS.  On x86, this will involve changing the LDT
-        * entry for this vcore to point to the TCB of the new user-thread. */
-       if (vcoreid == 0) {
-               handle_events(vcoreid);
-               set_tls_desc(core0_tls, 0);
-               assert(__vcoreid == 0); /* in case anyone uses this */
-               /* Load silly state (Floating point) too */
-               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
-               panic("should never see me!");
-       }       
-/* end: stuff userspace needs to do to handle notifications */
-
-       /* all other vcores are down here */
-       mcs_barrier_wait(&b, vcoreid);
-
-       udelay(1000000);
-       if (vcoreid == 1)
-               printf("Proc %d's vcores are yielding\n", getpid());
-       sys_yield(0);
-
-       while(1);
-}
-
diff --git a/tests/msr_get_singlecore.c b/tests/msr_get_singlecore.c
deleted file mode 100644 (file)
index bfb7a3d..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* tests/msr_get_singlecore.c
- *
- * Like msr_get_cores.c, but it only gets one core. */
-
-
-#include <parlib.h>
-#include <ros/mman.h>
-#include <ros/resource.h>
-#include <ros/procdata.h>
-#include <ros/bcq.h>
-#include <arch/arch.h>
-#include <stdio.h>
-#include <vcore.h>
-#include <mcs.h>
-#include <timing.h>
-#include <rassert.h>
-#include <uthread.h>
-#include <event.h>
-
-mcs_barrier_t b;
-
-void *core0_tls = 0;
-uint64_t begin = 0, end = 0;
-volatile bool core1_up = FALSE;
-
-int main(int argc, char** argv)
-{
-       uint32_t vcoreid = vcore_id();
-       int retval = 0;
-
-       mcs_barrier_init(&b, max_vcores());
-
-/* begin: stuff userspace needs to do before switching to multi-mode */
-       vcore_init();
-       #if 0
-       /* tell the kernel where and how we want to receive notifications */
-       struct notif_method *nm;
-       for (int i = 0; i < MAX_NR_NOTIF; i++) {
-               nm = &__procdata.notif_methods[i];
-               nm->flags |= NOTIF_WANTED | NOTIF_MSG | NOTIF_IPI;
-               nm->vcoreid = i % 2; // vcore0 or 1, keepin' it fresh.
-       }
-       #endif
-       /* Need to save this somewhere that you can find it again when restarting
-        * core0 */
-       core0_tls = get_tls_desc(0);
-       /* Need to save our floating point state somewhere (like in the
-        * user_thread_tcb so it can be restarted too */
-/* end: stuff userspace needs to do before switching to multi-mode */
-
-       /* get into multi mode */
-       retval = vcore_request(1);
-       if (retval)
-               printf("Fucked!\n");
-
-       printf("Proc %d requesting another vcore\n", getpid());
-       begin = read_tsc();
-       retval = vcore_request(1);
-       if (retval)
-               printf("Fucked!\n");
-       while (!core1_up)
-               cpu_relax;
-       end = read_tsc();
-       printf("Took %llu usec (%llu nsec) to receive 1 core (cold).\n",
-              udiff(begin, end), ndiff(begin, end));
-       printf("[T]:002:%llu:%llu:1:C.\n",
-              udiff(begin, end), ndiff(begin, end));
-       core1_up = FALSE;
-       udelay(2000000);
-       printf("Proc %d requesting the vcore again\n", getpid());
-       begin = read_tsc();
-       retval = vcore_request(1);
-       if (retval)
-               printf("Fucked!\n");
-       while (!core1_up)
-               cpu_relax();
-       end = read_tsc();
-       printf("Took %llu usec (%llu nsec) to receive 1 core (warm).\n",
-              udiff(begin, end), ndiff(begin, end));
-       printf("[T]:002:%llu:%llu:1:W.\n",
-              udiff(begin, end), ndiff(begin, end));
-       return 0;
-}
-
-void vcore_entry(void)
-{
-       uint32_t vcoreid = vcore_id();
-
-/* begin: stuff userspace needs to do to handle notifications */
-       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
-       struct preempt_data *vcpd;
-       vcpd = &__procdata.vcore_preempt_data[vcoreid];
-       
-       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
-        * set the appropriate TLS.  On x86, this will involve changing the LDT
-        * entry for this vcore to point to the TCB of the new user-thread. */
-       if (vcoreid == 0) {
-               handle_events(vcoreid);
-               set_tls_desc(core0_tls, 0);
-               assert(__vcoreid == 0); /* in case anyone uses this */
-               /* Load silly state (Floating point) too */
-               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
-               panic("should never see me!");
-       }       
-/* end: stuff userspace needs to do to handle notifications */
-
-       /* all other vcores are down here */
-       core1_up = TRUE;
-
-       while (core1_up)
-               cpu_relax();
-       printf("Proc %d's vcore %d is yielding\n", getpid(), vcoreid);
-       sys_yield(0);
-
-       while(1);
-}
-
diff --git a/tests/msr_nice_while.c b/tests/msr_nice_while.c
deleted file mode 100644 (file)
index 7f76718..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* tests/msr_dumb_while.c
- *
- * This requests the max_vcores in the system, then just while loops in a
- * userthread.  The pthread code will nicely yield if it detects an incoming
- * preemption. */
-
-#include <stdlib.h>
-#include <vcore.h>
-#include <pthread.h>
-#include <rassert.h>
-#include <event.h>
-#include <uthread.h>
-
-void *while_thread(void *arg)
-{
-       while (1);
-}
-
-int main(int argc, char** argv)
-{
-       pthread_t *my_threads = malloc(sizeof(pthread_t) * max_vcores());
-
-       /* set up to receive the PREEMPT_PENDING event.  EVENT_VCORE_APPRO tells the
-        * kernel to send the msg to whichever vcore is appropriate.  Pthread code
-        * will see the preemption and yield. */
-       struct event_queue *ev_q = get_event_q();
-       ev_q->ev_flags = EVENT_IPI | EVENT_NOMSG | EVENT_VCORE_APPRO;
-       register_kevent_q(ev_q, EV_PREEMPT_PENDING);
-
-       /* actually only need one less, since the _S will be pthread 0 */
-       for (int i = 0; i < max_vcores() - 1; i++)
-               pthread_create(&my_threads[i], NULL, &while_thread, NULL);
-
-       assert(num_vcores() == max_vcores());
-       while (1);
-
-       /* should never make it here */
-       return -1;
-}
diff --git a/tests/msr_single_while.c b/tests/msr_single_while.c
deleted file mode 100644 (file)
index f0f5234..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* tests/msr_single_while.c
- *
- * just sits in a while loop in _S mode. */
-
-int main(int argc, char** argv)
-{
-       while(1);
-       return -1;
-}
-
diff --git a/tests/null.c b/tests/null.c
deleted file mode 100644 (file)
index 64f1885..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdlib.h>
-
-int main(int argc, char** argv)
-{
-       return 0;
-}
diff --git a/tests/old/appender.c b/tests/old/appender.c
new file mode 100644 (file)
index 0000000..7238817
--- /dev/null
@@ -0,0 +1,40 @@
+#include <stdio.h> 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <arch/arch.h>
+#include <unistd.h>
+#include <errno.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define WRITE_AMOUNT 4096
+int main(int argc, char *argv[]) 
+{ 
+       int retval;
+       char wbuf[WRITE_AMOUNT];
+       if (argc < 2) {
+               printf("Appends some shit to the end of a text file\n");
+               printf("Usage: appender FILENAME\n");
+               return -1;
+       }
+
+       int fd = open(argv[1], O_RDWR);
+       if (!fd) {
+               printf("Unable to open %s\n", argv[1]);
+               return -1;
+       }
+
+       for (int i = 0; i < WRITE_AMOUNT; i += 4) {
+               wbuf[i + 0] = 'X';
+               wbuf[i + 1] = 'M';
+               wbuf[i + 2] = 'E';
+               wbuf[i + 3] = ' ';
+       }
+       
+       lseek(fd, 0, SEEK_END);
+       retval = write(fd, wbuf, WRITE_AMOUNT);
+       printf("Tried to write %d bytes, got retval: %d\n", WRITE_AMOUNT, retval);
+       return 0;
+}
diff --git a/tests/old/arsc_mt.c b/tests/old/arsc_mt.c
new file mode 100644 (file)
index 0000000..218e545
--- /dev/null
@@ -0,0 +1,52 @@
+#ifdef CONFIG_ARSC_SERVER
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <vcore.h>
+#include <parlib.h>
+#include <ros/syscall.h>
+#include <arc.h>
+#include <stdio.h>
+
+#define NUM_THREADS 4
+
+pthread_t t1;
+
+async_desc_t desc1;
+
+syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
+                     void (*cleanup_handler)(void*), void* cleanup_data)
+{                                                                                                                     
+       return arc_call(SYS_cputs, s, len);
+}
+
+void *syscall_thread(void* arg)
+{
+       char testme ='a';
+       char buf[20] = {0};
+       sprintf(buf, "%d", (pthread_self()->id % 10) );
+       char tid = buf[0];
+       syscall_desc_t* sysdesc;
+       sysdesc = sys_cputs_async(&tid, 1, NULL, NULL);
+       assert (-1 != waiton_syscall(sysdesc));
+}
+
+int main(int argc, char** argv){
+       int pid = sys_getpid();
+       pthread_t *my_threads = malloc(sizeof(pthread_t) * NUM_THREADS);
+       char testme = 't';
+       printf ("multi thread - init arsc \n");
+       init_arc(&SYS_CHANNEL);
+       for (int i = 0; i < NUM_THREADS ; i++)
+               pthread_create(&my_threads[i], NULL, &syscall_thread, NULL);
+       
+       for (int i = 0; i < NUM_THREADS; i++){
+               pthread_join(my_threads[i], NULL);
+       }
+
+       printf("multi thread - end\n");
+}
+#else
+int main(){};
+#endif
diff --git a/tests/old/arsc_test.c b/tests/old/arsc_test.c
new file mode 100644 (file)
index 0000000..58321fa
--- /dev/null
@@ -0,0 +1,44 @@
+#ifdef CONFIG_ARSC_SERVER
+#include <parlib.h>
+#include <vcore.h>
+#include <ros/syscall.h>
+#include <arc.h>
+#include <stdio.h>
+
+syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
+                     void (*cleanup_handler)(void*), void* cleanup_data)
+{                                                                                                                     
+    /*// could just hardcode 4 0's, will eventually wrap this marshaller anyway                                         
+       syscall_desc_t* desc;
+    syscall_req_t syscall = {REQ_alloc, cleanup_handler, cleanup_data,
+                                                       SYS_cputs,{(uint32_t)s, len, [2 ... (NUM_SYSCALL_ARGS-1)] 0} };                          
+    syscall.cleanup = cleanup_handler;                                                                                  
+    syscall.data = cleanup_data;
+    async_syscall(&syscall, &desc);
+       */
+       return arc_call(SYS_cputs, s, len);
+}
+
+int main(int argc, char** argv){
+       int pid = sys_getpid();
+       char testme = 't';
+       printf ("single thread - init arsc \n");
+       syscall_desc_t* sysdesc[2];
+       syscall_rsp_t sysrsp;
+       init_arc(&SYS_CHANNEL);
+
+       printf ("single thread - init complete \n");
+       // cprintf_async(&desc1, "Cross-Core call 1, coming from process %08x\n", pid);
+       sysdesc[0] = sys_cputs_async(&testme, 1, NULL, NULL);
+       sysdesc[1] = sys_cputs_async(&testme, 1, NULL, NULL);
+
+       printf ("single thread - call placed \n");
+       //ignore return value
+       assert(-1 != waiton_syscall(sysdesc[0]));
+       assert(-1 != waiton_syscall(sysdesc[1]));
+       printf ("single thread - dummy call \n");       
+}
+
+#else
+int main(){};
+#endif
diff --git a/tests/old/badsegment.c b/tests/old/badsegment.c
new file mode 100644 (file)
index 0000000..6926bf3
--- /dev/null
@@ -0,0 +1,14 @@
+// program to cause a general protection exception
+
+int main(int argc, char** argv)
+{
+       // Try to load the kernel's TSS selector into the DS register.
+       //asm volatile("movw $28,%ax; movw %ax,%ds");
+  
+       // DP: 0x28 == 40
+       #ifdef __i386__
+       asm volatile("movw $40,%ax; movw %ax,%ds");
+       #endif
+       return 0;
+}
+
diff --git a/tests/old/breakpoint.c b/tests/old/breakpoint.c
new file mode 100644 (file)
index 0000000..124bc6c
--- /dev/null
@@ -0,0 +1,10 @@
+// program to cause a breakpoint trap
+
+#include <arch/arch.h>
+
+int main(int argc, char** argv)
+{
+       breakpoint();
+       return 0;
+}
+
diff --git a/tests/old/buggyhello.c b/tests/old/buggyhello.c
new file mode 100644 (file)
index 0000000..05232e9
--- /dev/null
@@ -0,0 +1,11 @@
+// buggy hello world -- unmapped pointer passed to kernel
+// kernel should destroy user process in response
+
+#include <parlib.h>
+
+int main(int argc, char** argv)
+{
+       sys_cputs((char*SAFE)TC(1), 1);
+       return 0;
+}
+
diff --git a/tests/old/condvar_test.c b/tests/old/condvar_test.c
new file mode 100644 (file)
index 0000000..725a501
--- /dev/null
@@ -0,0 +1,152 @@
+#include <stdio.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+/* OS dependent #incs */
+#include <parlib.h>
+#include <vcore.h>
+#include <timing.h>
+
+#define MAX_NR_TEST_THREADS 1000
+
+pthread_t my_threads[MAX_NR_TEST_THREADS];
+void *my_retvals[MAX_NR_TEST_THREADS];
+
+
+/* Funcs and global vars for test_cv() */
+pthread_cond_t local_cv;
+pthread_cond_t *cv = &local_cv;
+pthread_mutex_t local_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t *pth_m = &local_mutex;
+
+atomic_t counter;
+volatile bool state = FALSE;           /* for test 3 */
+
+void *__test_pthread_cond_signal(void *arg)
+{
+       if (atomic_read(&counter) % 4)
+               pthread_cond_signal(cv);
+       else
+               pthread_cond_broadcast(cv);
+       atomic_dec(&counter);
+}
+
+void *__test_pthread_cond_waiter(void *arg)
+{
+       pthread_mutex_lock(pth_m);
+       /* check state, etc */
+       pthread_cond_wait(cv, pth_m);
+       pthread_mutex_unlock(pth_m);
+       atomic_dec(&counter);
+}
+
+void *__test_pthread_cond_waiter_t3(void *arg)
+{
+       udelay((long)arg);
+       /* if state == false, we haven't seen the signal yet */
+       pthread_mutex_lock(pth_m);
+       printd("Came in, saw state %d\n", state);
+       while (!state) {
+               cpu_relax();
+               pthread_cond_wait(cv, pth_m);   /* unlocks and relocks */
+       }
+       pthread_mutex_unlock(pth_m);
+       /* Make sure we are done, tell the controller we are done */
+       cmb();
+       assert(state);
+       atomic_dec(&counter);
+}
+
+int main(void)
+{
+       int nr_msgs;
+       pthread_lib_init();
+       pthread_cond_init(cv, 0);
+       pthread_mutex_init(pth_m, 0);
+
+       /* Test 0: signal without waiting */
+       pthread_cond_broadcast(cv);
+       pthread_cond_signal(cv);
+       printf("test_cv: signal without waiting complete\n");
+
+       /* Test 1: single / minimal shit */
+       nr_msgs = max_vcores() - 1;
+       atomic_init(&counter, nr_msgs);
+       for (int i = 0; i < nr_msgs; i++) {
+               if (pthread_create(&my_threads[i], NULL, &__test_pthread_cond_waiter,
+                   NULL))
+                       perror("pth_create failed");
+       }
+       udelay(1000000);
+       pthread_cond_signal(cv);
+       /* wait for one to make it */
+       while (atomic_read(&counter) != nr_msgs - 1)
+               pthread_yield();
+       printf("test_cv: single signal complete\n");
+       pthread_cond_broadcast(cv);
+       for (int i = 0; i < nr_msgs; i++)
+               pthread_join(my_threads[i], &my_retvals[i]);
+       printf("test_cv: broadcast signal complete\n");
+
+       /* Test 2: shitloads of waiters and signalers */
+       nr_msgs = MAX_NR_TEST_THREADS;
+       atomic_init(&counter, nr_msgs);
+       for (int i = 0; i < nr_msgs; i++) {
+               if (i % 5) {
+                       if (pthread_create(&my_threads[i], NULL,
+                           &__test_pthread_cond_waiter, NULL))
+                               perror("pth_create failed");
+               } else {
+                       if (pthread_create(&my_threads[i], NULL,
+                           &__test_pthread_cond_signal, NULL))
+                               perror("pth_create failed");
+               }
+       }
+       pthread_yield();
+       while (atomic_read(&counter)) {
+               cpu_relax();
+               pthread_cond_broadcast(cv);
+               pthread_yield();
+       }
+       for (int i = 0; i < nr_msgs; i++)
+               pthread_join(my_threads[i], &my_retvals[i]);
+       printf("test_cv: massive message storm complete\n");
+
+       /* Test 3: basic one signaller, one receiver.  we want to vary the amount of
+        * time the sender and receiver delays, starting with (1ms, 0ms) and ending
+        * with (0ms, 1ms).  At each extreme, such as with the sender waiting 1ms,
+        * the receiver/waiter should hit the "check and wait" point well before the
+        * sender/signaller hits the "change state and signal" point.
+        *
+        * Need to make sure we are running in parallel here.  Temp turned off the
+        * 2LSs VC management and got up to 2 VC.  Assuming no preemption. */
+       pthread_can_vcore_request(FALSE);       /* 2LS won't manage vcores */
+       while (num_vcores() < 2)
+               vcore_request(1);
+       for (long i = 0; i < 1000; i++) {
+               for (int j = 0; j < 10; j++) {  /* some extra chances at each point */
+                       state = FALSE;
+                       /* client waits for i usec */
+                       if (pthread_create(&my_threads[0], NULL,
+                           &__test_pthread_cond_waiter_t3, (void*)i))
+                               perror("pth_create failed");
+                       cmb();
+                       udelay(1000 - i);       /* senders wait time: 1000..0 */
+                       /* Need to lock the mutex when touching state and signalling about
+                        * that state (atomically touch and signal).  Thanks pthreads, for
+                        * mandating a cond_signal that doesn't require locking. */
+                       pthread_mutex_lock(pth_m);
+                       state = TRUE;
+                       pthread_cond_signal(cv);
+                       pthread_mutex_unlock(pth_m);
+                       /* they might not have run at all yet (in which case they lost the
+                        * race and don't need the signal).  but we need to wait til they're
+                        * done */
+                       pthread_join(my_threads[0], my_retvals[0]);
+               }
+       }
+       pthread_can_vcore_request(TRUE);        /* 2LS controls VCs again */
+       printf("test_cv: single sender/receiver complete\n");
+}
diff --git a/tests/old/cpp_streams.cc b/tests/old/cpp_streams.cc
new file mode 100644 (file)
index 0000000..1e9f30a
--- /dev/null
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <errno.h>
+
+using namespace std;
+
+int main() {
+       string line;
+       ifstream myfile;
+       errno = 0;
+       myfile.open("hello.txt", ifstream::in);
+       if (errno)
+               perror("Unable to open (hello.txt):");
+       if (myfile.is_open()) {
+               while (myfile.good()) {
+                 getline(myfile, line);
+                 cout << line << endl;
+               }
+               myfile.close();
+               cout << "Stream test passed" << endl;
+       } else {
+               cout << "Unable to open file"; 
+       }
+       return 0;
+}
diff --git a/tests/old/divzero.c b/tests/old/divzero.c
new file mode 100644 (file)
index 0000000..59dbf18
--- /dev/null
@@ -0,0 +1,12 @@
+// buggy program - causes a divide by zero exception
+
+#include <stdio.h>
+
+int zero;
+
+int main(int argc, char** argv)
+{
+       printf("1/0 is %08x!\n", 1/zero);
+       return 0;
+}
+
diff --git a/tests/old/dtls_test.c b/tests/old/dtls_test.c
new file mode 100644 (file)
index 0000000..1087fb2
--- /dev/null
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* OS dependent #incs */
+#include <parlib.h>
+
+#define NR_TEST_THREADS 10
+#define NUM_PTHREAD_KEYS 10
+pthread_t my_threads[NR_TEST_THREADS];
+void *my_retvals[NR_TEST_THREADS];
+pthread_key_t pthread_keys[NUM_PTHREAD_KEYS];
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void *thread(void* arg)
+{      
+  long *dtls_value[NUM_PTHREAD_KEYS];
+  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
+    dtls_value[i] = malloc(sizeof(long));
+    *dtls_value[i] = (long)pthread_self() + i;
+    pthread_setspecific(pthread_keys[i], dtls_value[i]);
+  }
+
+  pthread_mutex_lock(&mutex);
+  long self = (long)pthread_self();
+  printf("In pthread %p (%ld)\n", (void*)self, self);
+  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
+    long *value = pthread_getspecific(pthread_keys[i]);
+    printf("  dtls_value[%d] = %ld\n", i, *value);
+  }
+  pthread_mutex_unlock(&mutex);
+
+  return (void*)(self);
+}
+
+static void dtls_dtor(void *dtls)
+{
+  pthread_mutex_lock(&mutex);
+  printf("Phread %p freeing dtls %p.\n", pthread_self(), dtls);
+  free(dtls);
+  pthread_mutex_unlock(&mutex);
+}
+
+int main(int argc, char** argv) 
+{
+  printf("Starting dtls test.\n");
+  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
+    pthread_key_create(&pthread_keys[i], dtls_dtor);
+  }
+  for (int i = 0; i < NR_TEST_THREADS; i++) {
+       if (pthread_create(&my_threads[i], NULL, &thread, NULL))
+               perror("pth_create failed");
+  }
+  for (int i = 0; i < NR_TEST_THREADS; i++) {
+       pthread_join(my_threads[i], &my_retvals[i]);
+  }
+  for(int i=0; i<NUM_PTHREAD_KEYS; i++) {
+    pthread_key_delete(pthread_keys[i]);
+  }
+  printf("Test complete!\n");
+} 
diff --git a/tests/old/eth_audio.c b/tests/old/eth_audio.c
new file mode 100644 (file)
index 0000000..2c0fc23
--- /dev/null
@@ -0,0 +1,137 @@
+#include <ros/resource.h>
+#include <ros/procdata.h>
+#include <ros/event.h>
+#include <ros/bcq.h>
+#include <parlib.h>
+#include <vcore.h>
+
+#include <stdio.h> 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <arch/arch.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <timing.h>
+#include <assert.h>
+#include <event.h>
+#include <uthread.h>
+
+void *core0_tls = 0;
+void *in_buf, *out_buf;
+
+/* Test program for the audio device.  mmap()s the stuff, sets up a notif
+ * handler, and switches to multi_mode.
+ *
+ * Note: this has a lot of mhello-like MCP infrastructure.  When Lithe is
+ * working, you won't need any of this.  Just the mmap stuff and the notif
+ * handler.  Stuff specific to the ethernet audio device is marked ETH_AUD. */
+int main() 
+{ 
+       int retval;
+       int in_fd, out_fd;
+       /* ETHAUD mmap the input and output buffers */
+       in_fd = open("/dev/eth_audio_in", O_RDONLY);
+       out_fd = open("/dev/eth_audio_out", O_RDWR);
+       assert(in_fd != -1);
+       assert(out_fd != -1);
+       in_buf = mmap(0, PGSIZE, PROT_READ, 0, in_fd, 0);
+       if (in_buf == MAP_FAILED) {
+               int err = errno;
+               perror("Can't mmap the input buf:");
+       }
+       out_buf = mmap(0, PGSIZE, PROT_READ | PROT_WRITE, MAP_POPULATE, out_fd, 0);
+       if (out_buf == MAP_FAILED) {
+               int err = errno;
+               perror("Can't mmap the output buf:");
+       }
+       //strncpy(out_buf, "Nanwan loves you!\n", 19);
+
+/* begin: stuff userspace needs to do before switching to multi-mode */
+       vcore_init();
+
+       /* ETHAUD Turn on Free apple pie (which is the network packet) */
+       enable_kevent(EV_FREE_APPLE_PIE, 0, EVENT_IPI);
+
+       /* Need to save this somewhere that you can find it again when restarting
+        * core0 */
+       core0_tls = get_tls_desc(0);
+       /* Need to save our floating point state somewhere (like in the
+        * user_thread_tcb so it can be restarted too */
+
+/* end: stuff userspace needs to do before switching to multi-mode */
+       /* ETHAUD */
+       /* Switch into _M mode */
+       retval = vcore_request(1);
+
+       /* Stay alive for a minute (will take interrupts) */
+       udelay(60000000);
+
+       printf("Eth aud, finishing up!\n");
+       /* Need to do unmap it, due to some limitations in the kernel */
+       munmap(in_buf, PGSIZE);
+       munmap(out_buf, PGSIZE);
+       close(in_fd);
+       close(out_fd);
+}
+
+/* ETHAUD, with some debugging commands... */
+void process_packet(void)
+{
+       //printf("Received a packet!\n");
+       //memset(out_buf, 0, PGSIZE);
+       memcpy(out_buf, in_buf, 1280);  /* size of the payload. */
+       memset(out_buf + 1280, 0, 4);   /* 4 bytes of control info. */
+       //printf("contents of out_buf %s\n", out_buf);
+}
+
+void vcore_entry(void)
+{
+       uint32_t vcoreid = vcore_id();
+       static bool first_time = TRUE;
+
+       printf("GIANT WARNING: this is ancient shit\n");
+/* begin: stuff userspace needs to do to handle events/notifications */
+
+       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
+       struct preempt_data *vcpd;
+       vcpd = &__procdata.vcore_preempt_data[vcoreid];
+       
+       /* Ghetto way to get just an event number */
+       unsigned int ev_type = get_event_type(&vcpd->ev_mbox_public);
+
+       /* ETHAUD app: process the packet if we got a notif */
+       if (ev_type == EV_FREE_APPLE_PIE)
+               process_packet();
+
+       if (vc->preempt_pending) {
+               printf("Oh crap, vcore %d is being preempted!  Yielding\n", vcoreid);
+               sys_yield(TRUE);
+               printf("After yield on vcore %d. I wasn't being preempted.\n", vcoreid);
+       }
+               
+       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
+        * set the appropriate TLS.  On x86, this will involve changing the LDT
+        * entry for this vcore to point to the TCB of the new user-thread. */
+       if (vcoreid == 0) {
+               handle_events(vcoreid);
+               set_tls_desc(core0_tls, 0);
+               assert(__vcoreid == 0); /* in case anyone uses this */
+               /* Load silly state (Floating point) too */
+               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
+               printf("should never see me!");
+       }       
+       /* unmask notifications once you can let go of the uthread_ctx and it is
+        * okay to clobber the transition stack.
+        * Check Documentation/processes.txt: 4.2.4.  In real code, you should be
+        * popping the tf of whatever user process you want (get off the x-stack) */
+       vcpd->notif_disabled = FALSE;
+       
+/* end: stuff userspace needs to do to handle notifications */
+       /* The other vcores will hit here. */
+       while (1)
+               cpu_relax();
+}
diff --git a/tests/old/evilhello.c b/tests/old/evilhello.c
new file mode 100644 (file)
index 0000000..1edac84
--- /dev/null
@@ -0,0 +1,13 @@
+// evil hello world -- kernel pointer passed to kernel
+// kernel should destroy user process in response
+
+#include <parlib.h>
+
+int main(int argc, char** argv)
+{
+       while(1);
+       // try to print the kernel entry point as a string!  mua ha ha!
+       sys_cputs((char*SAFE)TC(0xc0100020), 100);
+       return 0;
+}
+
diff --git a/tests/old/faultread.c b/tests/old/faultread.c
new file mode 100644 (file)
index 0000000..3cf8a3f
--- /dev/null
@@ -0,0 +1,10 @@
+// buggy program - faults with a read from location zero
+
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{ 
+       printf("I read %08x from location 0!\n", *(unsigned*)0);
+       return 0;
+}
+
diff --git a/tests/old/faultreadkernel.c b/tests/old/faultreadkernel.c
new file mode 100644 (file)
index 0000000..cef359f
--- /dev/null
@@ -0,0 +1,10 @@
+// buggy program - faults with a read from kernel space
+
+#include <stdio.h>
+
+int main(int argc, char** argv)
+{
+       printf("I read %08x from location 0xf0100000!\n", *(unsigned*)0xf0100000);
+       return 0;
+}
+
diff --git a/tests/old/faultwrite.c b/tests/old/faultwrite.c
new file mode 100644 (file)
index 0000000..05b1861
--- /dev/null
@@ -0,0 +1,8 @@
+// buggy program - faults with a write to location zero
+
+int main(int argc, char** argv)
+{
+       *(unsigned*)0 = 0;
+       return 0;
+}
+
diff --git a/tests/old/faultwritekernel.c b/tests/old/faultwritekernel.c
new file mode 100644 (file)
index 0000000..8b07449
--- /dev/null
@@ -0,0 +1,9 @@
+// buggy program - faults with a write to a kernel location
+
+
+int main(int argc, char** argv)
+{ 
+       *(unsigned*)0xf0100000 = 0;
+       return 0;
+}
+
diff --git a/tests/old/fork.c b/tests/old/fork.c
new file mode 100644 (file)
index 0000000..b7efa42
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int main(int argc, char** argv)
+{
+       int status;
+       pid_t pid = 0;
+       pid = fork();
+       if (pid) {
+               printf("Hello world from parent!!\n");
+               waitpid(pid, &status, 0);
+       } else {
+               printf("Hello world from child!!\n");
+               printf("Child trying to exec Hello...\n");
+               execv("/bin/hello", argv);
+       }
+       return 0;
+}
diff --git a/tests/old/fp_test.c b/tests/old/fp_test.c
new file mode 100644 (file)
index 0000000..eaf8fb2
--- /dev/null
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main(int argc, char** argv) 
+{
+       volatile float x = 2.5;
+       volatile float y = 5.0;
+       volatile float var = x*y;
+       printf("value decimal: %d\n", (int)var);
+//     printf("value floating: %f\n", var);
+
+//     int x = 25;
+//     int y = 50;
+//     int var = x*y;
+//     printf("value: %d\n", var);
+} 
diff --git a/tests/old/fpperf.cc b/tests/old/fpperf.cc
new file mode 100644 (file)
index 0000000..f0b3dc6
--- /dev/null
@@ -0,0 +1,107 @@
+/* Chunk of code from stage 6 of fluidanimate, running on its own in a single
+ * process, meant to run on either linux or akaros (check the ifdef below). */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <float.h>
+#include <math.h>
+#include <cstdlib>
+#include <cstring>
+#include <algorithm>
+#include <sys/time.h>
+#include <pthread.h>
+
+typedef float fptype;
+
+class Vec3
+{
+public:
+  fptype x, y, z;
+
+  Vec3() {}
+  Vec3(fptype _x, fptype _y, fptype _z) : x(_x), y(_y), z(_z) {}
+
+  fptype  GetLengthSq() const         { return x*x + y*y + z*z; }
+  fptype  GetLength() const           { return sqrtf(GetLengthSq()); }
+  Vec3 &  Normalize()                 { return *this /= GetLength(); }
+
+  bool    operator == (Vec3 const &v) { return (x == v.x) && (y == v.y) && (z += v.z); }
+  Vec3 &  operator += (Vec3 const &v) { x += v.x;  y += v.y; z += v.z; return *this; }
+  Vec3 &  operator -= (Vec3 const &v) { x -= v.x;  y -= v.y; z -= v.z; return *this; }
+  Vec3 &  operator *= (fptype s)      { x *= s;  y *= s; z *= s; return *this; }
+  Vec3 &  operator /= (fptype s)      { fptype tmp = 1.f/s; x *= tmp;  y *= tmp; z *= tmp; return *this; }
+
+  Vec3    operator + (Vec3 const &v) const    { return Vec3(x+v.x, y+v.y, z+v.z); }
+  Vec3    operator + (fptype const &f) const  { return Vec3(x+f, y+f, z+f); }
+  Vec3    operator - () const                 { return Vec3(-x, -y, -z); }
+  Vec3    operator - (Vec3 const &v) const    { return Vec3(x-v.x, y-v.y, z-v.z); }
+  Vec3    operator * (fptype s) const         { return Vec3(x*s, y*s, z*s); }
+  Vec3    operator / (fptype s) const         { fptype tmp = 1.f/s; return Vec3(x*tmp, y*tmp, z*tmp); }
+
+  fptype  operator * (Vec3 const &v) const    { return x*v.x + y*v.y + z*v.z; }
+};
+
+float rand_f1 = 3.14;
+float rand_f2 = 6.282222;
+float rand_f3 = 443.38383;
+float rand_f4;
+float rand_f5;
+static const fptype doubleRestDensity = 2000.0;
+static const fptype viscosity = 0.4;
+
+static const Vec3 rand_v3_1(0.1, -9.8, 30.0);
+static const Vec3 rand_v3_2(0.2, -90.8, 0.5);
+static const Vec3 rand_v3_3(7.3, -444.8, 8.0);
+static const Vec3 rand_v3_4(8.4, -99.8, 0.8);
+
+Vec3 output(0, 0, 0);
+
+int main(int argc, char **argv)
+{
+       struct timeval start_tv = {0};
+       struct timeval end_tv = {0};
+       uint64_t usec_diff;
+       if (argc < 3) {
+               printf("Need 2 args\n");
+               exit(-1);
+       }
+
+       /* Disable this if you want to compile for linux with the i686-ros-g++ */
+       #if 1
+       # ifdef __ros__
+       if (argc == 4) {
+               pthread_can_vcore_request(FALSE);
+               pthread_lib_init();                             
+               printf("Vcore %d mapped to pcore %d\n", 0, __procinfo.vcoremap[0].pcoreid);
+       }
+       # endif
+       #endif
+
+       rand_f4 = (float)atoi(argv[1]);
+       rand_f5 = (float)atoi(argv[2]);
+       if (gettimeofday(&start_tv, 0))
+               perror("Start time error...");
+       for (int i = 0; i < 300000000; i++) {
+       
+               Vec3 disp = rand_v3_1 - rand_v3_2 * rand_f5;
+               fptype distSq = disp.GetLengthSq();
+               fptype dist = sqrtf(std::max(distSq, (fptype)1e-12));
+               fptype hmr = rand_f1 - dist;
+               
+               Vec3 acc = disp * rand_f2 * (hmr*hmr/dist)
+                          * (rand_f3 + rand_f4 + rand_f5 - doubleRestDensity);
+               acc += (rand_v3_3 - rand_v3_4 * rand_f5) * viscosity * hmr;
+               acc /= rand_f5 * rand_f1;
+               
+               output += acc;
+       }
+       float ret = output.GetLengthSq();
+       if (gettimeofday(&end_tv, 0))
+               perror("End time error...");
+       usec_diff = (end_tv.tv_sec - start_tv.tv_sec) * 1000000 +
+                   (end_tv.tv_usec - start_tv.tv_usec);
+       printf("%f, took %.3f sec\n", ret, (float)usec_diff / 1000000);
+       return 0;
+}
diff --git a/tests/old/hart_test.c b/tests/old/hart_test.c
new file mode 100644 (file)
index 0000000..51fb0d4
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char** argv) 
+{
+       printf("Goodbye cruel world!!\n");
+} 
diff --git a/tests/old/idle.c b/tests/old/idle.c
new file mode 100644 (file)
index 0000000..7570069
--- /dev/null
@@ -0,0 +1,23 @@
+#include <parlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* This will keep a core from spinning forever, but will also allow it to still
+ * schedule() and run _S processes.  arg1 is the number of loops (0 for
+ * forever), and arg2 is how many usec to wait per loop. */
+int main(int argc, char** argv)
+{
+       unsigned long nr_loops = 1;                     /* default, 1 loop */
+       unsigned long timeout = 5000000;        /* default, 5 sec */
+       int i = 0;
+       if (argc > 1)
+               nr_loops = strtol(argv[1], 0, 10);
+       if (argc > 2)
+               timeout = strtol(argv[2], 0, 10);
+       printf("Idling for %d usec for %d loops\n", timeout, nr_loops);
+       while (!nr_loops || i++ < nr_loops) {
+               sys_halt_core(timeout);
+               sys_yield(0);
+       }
+       return 0;
+}
diff --git a/tests/old/kern_tests.h b/tests/old/kern_tests.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/old/manycore_test.c b/tests/old/manycore_test.c
new file mode 100644 (file)
index 0000000..09ea55b
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <assert.h>
+#include <vcore.h>
+#include <parlib.h>
+#include <mcs.h>
+#include <uthread.h>
+
+mcs_barrier_t b;
+
+void do_work_son(int vcoreid)
+{
+       int pcoreid = sys_getpcoreid();
+       int pid = sys_getpid();
+       printf("Hello! My Process ID: %d My VCoreID: %d My CPU: %d\n", pid, vcoreid,
+              pcoreid);
+       mcs_barrier_wait(&b,vcoreid);
+}
+
+void vcore_entry()
+{
+       assert(vcore_id() > 0);
+       do_work_son(vcore_id());
+}
+
+int main(int argc, char** argv)
+{
+       assert(vcore_id() == 0);
+       mcs_barrier_init(&b,max_vcores());
+       vcore_request(max_vcores()-1);
+       do_work_son(0);
+       return 0;
+}
diff --git a/tests/old/mproctests.c b/tests/old/mproctests.c
new file mode 100644 (file)
index 0000000..b6f231a
--- /dev/null
@@ -0,0 +1,170 @@
+#include <arch/arch.h>
+#include <parlib.h>
+#include <rassert.h>
+#include <stdlib.h>
+#include <vcore.h>
+#include <ros/mman.h>
+#include <ros/resource.h>
+#include <stdio.h>
+#include <timing.h>
+#include <uthread.h>
+
+#define TEST_MMAP                                       1
+#define TEST_ONE_CORE                           2
+#define TEST_ASK_FOR_TOO_MANY_CORES     3
+#define TEST_INCREMENTAL_CHANGES        4
+#define TEST_YIELD_OUT_OF_ORDER                 5
+#define TEST_YIELD_0_OUT_OF_ORDER       6
+#define TEST_YIELD_ALL               7
+#define TEST_SWITCH_TO_RUNNABLE_S       8
+#define TEST_CRAZY_YIELDS                       9
+#define TEST_CONCURRENT_SYSCALLS       10
+
+int test = TEST_SWITCH_TO_RUNNABLE_S;
+
+static void global_tests(uint32_t vcoreid);
+
+int main(int argc, char** argv)
+{
+       uint32_t vcoreid;
+       int retval;
+       vcore_init();
+
+       if ((vcoreid = vcore_id())) {
+               printf("Should never see me! (from vcore %d)\n", vcoreid);
+       } else { // core 0
+               printf("Hello from else vcore 0\n");
+               printf("Multi-Goodbye, world, from PID: %d!\n", sys_getpid());
+               switch (test) {
+                       case TEST_MMAP:
+                               printf("Testing MMAP\n");
+                               void *CT(8*PGSIZE) addr;
+                               addr = sys_mmap((void*SNT)USTACKTOP - 20*PGSIZE, 8*PGSIZE, 3,
+                                               MAP_FIXED | MAP_ANONYMOUS, -1, 0);
+                               printf("got addr = 0x%08x\n", addr);
+                               *(int*)addr = 0xdeadbeef;
+                               *(int*)(addr + 3*PGSIZE) = 0xcafebabe;
+                               // these should work
+                               printf("reading addr: 0x%08x\n", *(int*)addr);
+                               printf("reading addr+3pg: 0x%08x\n", *(int*)(addr + 3*PGSIZE));
+                               // this should fault
+                               printf("Should page fault and die now.\n");
+                               { TRUSTEDBLOCK
+                               *(int*)(addr - 3*PGSIZE) = 0xdeadbeef;
+                               }
+                               printf("Should not see me!!!!!!!!!!!!!!!!!!\n");
+                               while(1);
+                       case TEST_ONE_CORE:
+                               retval = vcore_request(1);
+                               printf("One core test's core0's retval: %d\n", retval);
+                               printf("Check to see it's on a worker core.\n");
+                               while(1);
+                       case TEST_ASK_FOR_TOO_MANY_CORES:
+                               retval = vcore_request(12);
+                               printf("Asked for too many, retval: %d\n", retval);
+                               return 0;
+                       case TEST_INCREMENTAL_CHANGES:
+                               retval = vcore_request(4);
+                               break;
+                       default:
+                               retval = vcore_request(5);
+               }
+               if (retval)
+                       panic("failed to allocate cores!");
+               printf("Should see me if you want to relocate core0's context "
+                       "when moving from RUNNING_S\n");
+       }
+
+       // vcore0 only below here
+       switch (test) {
+               case TEST_YIELD_OUT_OF_ORDER:
+                       udelay(10000000);
+                       printf("Core 2 should have yielded, asking for another\n");
+                       retval = vcore_request(5);
+                       break;
+               case TEST_YIELD_0_OUT_OF_ORDER:
+                       udelay(5000000);
+                       printf("Core %d yielding\n", vcoreid);
+                       sys_yield(0);
+                       printf("Core 0 came back where it left off in RUNNING_M!!!\n");
+                       break;
+       }
+       global_tests(vcoreid);
+       printf("Vcore %d Done!\n", vcoreid);
+       while (1);
+       return 0;
+}
+
+void vcore_entry(void)
+{
+       uint32_t vcoreid;
+       static int first_time = 1; // used by vcore2
+       int retval;
+
+       vcoreid = vcore_id();
+       printf("Hello from vcore_entry in vcore %d\n", vcoreid);
+
+       if ((vcoreid == 2) && first_time) {
+               first_time = 0;
+               switch (test) {
+                       case TEST_INCREMENTAL_CHANGES:
+                               // Testing asking for less than we already have
+                               udelay(1000000);
+                               printf("Asking for too few:\n");
+                               retval = vcore_request(2);
+                               printf("Should be -EINVAL(7): %d\n", retval);
+                               // Testing getting more while running
+                               printf("Asking for more while running:\n");
+                               udelay(1000000);
+                               retval = vcore_request(5);
+                               printf("core2's retval: %d\n", retval);
+                               break;
+                       case TEST_YIELD_OUT_OF_ORDER:
+                               printf("Core %d yielding\n", vcoreid);
+                               sys_yield(0);
+                               break;
+                       case TEST_YIELD_0_OUT_OF_ORDER:
+                               udelay(7500000);
+                               printf("Core 0 should have yielded, asking for another\n");
+                               retval = vcore_request(5);
+               }
+       }
+       global_tests(vcoreid);
+       printf("Vcore %d Done!\n", vcoreid);
+}
+
+static void global_tests(uint32_t vcoreid)
+{
+       int retval;
+       switch (test) {
+               case TEST_YIELD_ALL:
+                       printf("Core %d yielding\n", vcoreid);
+                       sys_yield(0);
+                       // should be RUNNABLE_M now, amt_wanted == 1
+                       while(1);
+               case TEST_SWITCH_TO_RUNNABLE_S:
+                       if (vcoreid == 2) {
+                               printf("Core %d trying to request 0/ switch to _S\n", vcoreid);
+                               udelay(3000000);
+                               retval = vcore_request(0);
+                               // will only see this if we are scheduled()
+                               printf("Core %d back up! (retval:%d)\n", vcoreid, retval);
+                               printf("And exiting\n");
+                               exit(0);
+                       } 
+                       while(1);
+               case TEST_CRAZY_YIELDS:
+                       udelay(300000*vcoreid);
+                       vcore_request(5);
+                       sys_yield(0);
+                       printf("should  never see me, unless you slip into *_S\n");
+                       break;
+               case TEST_CONCURRENT_SYSCALLS:
+                       for (int i = 0; i < 10; i++) {
+                               for (int j = 0; j < 100; j++)
+                                       sys_null();
+                               printf("Hello from vcore %d, iteration %d\n", vcoreid, i);
+                       }
+                       break;
+       }
+}
diff --git a/tests/old/msr_cycling_vcores.c b/tests/old/msr_cycling_vcores.c
new file mode 100644 (file)
index 0000000..2713719
--- /dev/null
@@ -0,0 +1,58 @@
+/* tests/msr_cycling_vcores.c
+ *
+ * This requests the max_vcores in the system, waits a bit, then gives them
+ * back, looping forever.  We can't give up all vcores, based on the current
+ * kernel, so we hold on to vcore0 to do the thinking. */
+
+#include <ros/resource.h>
+#include <parlib.h>
+#include <stdio.h>
+#include <vcore.h>
+#include <timing.h>
+#include <mcs.h>
+#include <uthread.h>
+
+mcs_barrier_t b;
+uint64_t begin = 0, end = 0;
+
+int main(int argc, char** argv)
+{
+       printf("Good chance this doesn't work anymore!\n");
+       mcs_barrier_init(&b, max_vcores());
+
+       vcore_request(max_vcores());
+       printf("We're screwed!\n");
+
+       /* should never make it here */
+       return -1;
+}
+
+void vcore_entry(void)
+{
+       uint32_t vcoreid = vcore_id();
+
+       if (vcoreid) {
+               mcs_barrier_wait(&b, vcoreid);
+               udelay(5000000);
+               if (vcoreid == 1)
+                       printf("Proc %d's vcores are yielding\n", getpid());
+               sys_yield(0);
+       } else {
+               /* trip the barrier here, all future times are in the loop */
+               mcs_barrier_wait(&b, vcoreid);
+               while (1) {
+                       udelay(15000000);
+                       printf("Proc %d requesting its cores again\n", getpid());
+                       begin = read_tsc();
+                       vcore_request(max_vcores() - 1); /* since we already have 1 */
+                       mcs_barrier_wait(&b, vcoreid);
+                       end = read_tsc();
+                       printf("Took %llu usec (%llu nsec) to get my yielded cores back.\n",
+                              udiff(begin, end), ndiff(begin, end));
+                       printf("[T]:010:%llu:%llu\n",
+                              udiff(begin, end), ndiff(begin, end));
+               }
+       }
+       printf("We're screwed!\n");
+       exit(-1);
+}
diff --git a/tests/old/msr_dumb_while.c b/tests/old/msr_dumb_while.c
new file mode 100644 (file)
index 0000000..0f965b5
--- /dev/null
@@ -0,0 +1,33 @@
+/* tests/msr_dumb_while.c
+ *
+ * This requests the max_vcores in the system, then just dumbly while loops.
+ * If you send it an NE_ALARM, it'll print its TSC. */
+
+#include <stdio.h>
+#include <vcore.h>
+#include <arch/arch.h>
+#include <event.h>
+#include <uthread.h>
+
+int main(int argc, char** argv)
+{
+       /* Get EV_ALARM on vcore 1, with IPI. */
+       enable_kevent(EV_ALARM, 1, EVENT_IPI | EVENT_VCORE_PRIVATE);
+
+       vcore_request(max_vcores());
+
+       /* should never make it here */
+       return -1;
+}
+
+void vcore_entry(void)
+{
+       struct preempt_data *vcpd = &__procdata.vcore_preempt_data[0];
+       vcpd->notif_disabled = FALSE;
+
+       unsigned int ev_type = get_event_type(&vcpd->ev_mbox_private);
+       if (ev_type == EV_ALARM)
+               printf("[T]:009:E:%llu\n", read_tsc());
+       while(1);
+}
+
diff --git a/tests/old/msr_get_cores.c b/tests/old/msr_get_cores.c
new file mode 100644 (file)
index 0000000..6784dd2
--- /dev/null
@@ -0,0 +1,116 @@
+/* tests/msr_get_cores.c
+ *
+ * This measures the time it takes to request and receive the max_vcores() in
+ * the system.  The clock starts before vcore_request(), which includes the time
+ * it takes to allocate transition stacks and TLS.  The clock stops after
+ * barriering in vcore_entry(), while vcore0 gets restarted and barriers.  You
+ * really want to restart vcore0's context so it releases the lock in
+ * vcore_request().
+ *
+ * This will measure both the hot and cold times, with the hot times not needing
+ * to have stacks mmaped and other things. */
+
+
+#include <parlib.h>
+#include <ros/mman.h>
+#include <ros/resource.h>
+#include <ros/procdata.h>
+#include <ros/bcq.h>
+#include <arch/arch.h>
+#include <stdio.h>
+#include <vcore.h>
+#include <mcs.h>
+#include <timing.h>
+#include <rassert.h>
+#include <uthread.h>
+#include <event.h>
+
+mcs_barrier_t b;
+
+void *core0_tls = 0;
+uint64_t begin = 0, end = 0;
+
+int main(int argc, char** argv)
+{
+       uint32_t vcoreid = vcore_id();
+       int retval = 0;
+
+       mcs_barrier_init(&b, max_vcores());
+
+/* begin: stuff userspace needs to do before switching to multi-mode */
+       vcore_init();
+       #if 0
+       /* tell the kernel where and how we want to receive notifications */
+       struct notif_method *nm;
+       for (int i = 0; i < MAX_NR_NOTIF; i++) {
+               nm = &__procdata.notif_methods[i];
+               nm->flags |= NOTIF_WANTED | NOTIF_MSG | NOTIF_IPI;
+               nm->vcoreid = i % 2; // vcore0 or 1, keepin' it fresh.
+       }
+       #endif
+       /* Need to save this somewhere that you can find it again when restarting
+        * core0 */
+       core0_tls = get_tls_desc(0);
+       /* Need to save our floating point state somewhere (like in the
+        * user_thread_tcb so it can be restarted too */
+/* end: stuff userspace needs to do before switching to multi-mode */
+
+       begin = read_tsc();
+       retval = vcore_request(max_vcores());
+       if (retval)
+               printf("Fucked!\n");
+       mcs_barrier_wait(&b, vcoreid);
+       end = read_tsc();
+
+       printf("Took %llu usec (%llu nsec) to receive %d cores (cold).\n",
+              udiff(begin, end), ndiff(begin, end), max_vcores());
+       printf("[T]:001:%llu:%llu:%d:C.\n",
+              udiff(begin, end), ndiff(begin, end), max_vcores());
+       udelay(5000000);
+       begin = read_tsc();
+       retval = vcore_request(max_vcores() - 1);
+       if (retval)
+               printf("Fucked!\n");
+       mcs_barrier_wait(&b, vcoreid);
+       end = read_tsc();
+       printf("Took %llu usec (%llu nsec) to receive %d cores (warm).\n",
+              udiff(begin, end), ndiff(begin, end), max_vcores());
+       printf("[T]:001:%llu:%llu:%d:W.\n",
+              udiff(begin, end), ndiff(begin, end), max_vcores());
+
+       return 0;
+}
+
+void vcore_entry(void)
+{
+       uint32_t vcoreid = vcore_id();
+
+/* begin: stuff userspace needs to do to handle notifications */
+       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
+       struct preempt_data *vcpd;
+       vcpd = &__procdata.vcore_preempt_data[vcoreid];
+       
+       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
+        * set the appropriate TLS.  On x86, this will involve changing the LDT
+        * entry for this vcore to point to the TCB of the new user-thread. */
+       if (vcoreid == 0) {
+               handle_events(vcoreid);
+               set_tls_desc(core0_tls, 0);
+               assert(__vcoreid == 0); /* in case anyone uses this */
+               /* Load silly state (Floating point) too */
+               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
+               panic("should never see me!");
+       }       
+/* end: stuff userspace needs to do to handle notifications */
+
+       /* all other vcores are down here */
+       mcs_barrier_wait(&b, vcoreid);
+
+       udelay(1000000);
+       if (vcoreid == 1)
+               printf("Proc %d's vcores are yielding\n", getpid());
+       sys_yield(0);
+
+       while(1);
+}
+
diff --git a/tests/old/msr_get_singlecore.c b/tests/old/msr_get_singlecore.c
new file mode 100644 (file)
index 0000000..bfb7a3d
--- /dev/null
@@ -0,0 +1,117 @@
+/* tests/msr_get_singlecore.c
+ *
+ * Like msr_get_cores.c, but it only gets one core. */
+
+
+#include <parlib.h>
+#include <ros/mman.h>
+#include <ros/resource.h>
+#include <ros/procdata.h>
+#include <ros/bcq.h>
+#include <arch/arch.h>
+#include <stdio.h>
+#include <vcore.h>
+#include <mcs.h>
+#include <timing.h>
+#include <rassert.h>
+#include <uthread.h>
+#include <event.h>
+
+mcs_barrier_t b;
+
+void *core0_tls = 0;
+uint64_t begin = 0, end = 0;
+volatile bool core1_up = FALSE;
+
+int main(int argc, char** argv)
+{
+       uint32_t vcoreid = vcore_id();
+       int retval = 0;
+
+       mcs_barrier_init(&b, max_vcores());
+
+/* begin: stuff userspace needs to do before switching to multi-mode */
+       vcore_init();
+       #if 0
+       /* tell the kernel where and how we want to receive notifications */
+       struct notif_method *nm;
+       for (int i = 0; i < MAX_NR_NOTIF; i++) {
+               nm = &__procdata.notif_methods[i];
+               nm->flags |= NOTIF_WANTED | NOTIF_MSG | NOTIF_IPI;
+               nm->vcoreid = i % 2; // vcore0 or 1, keepin' it fresh.
+       }
+       #endif
+       /* Need to save this somewhere that you can find it again when restarting
+        * core0 */
+       core0_tls = get_tls_desc(0);
+       /* Need to save our floating point state somewhere (like in the
+        * user_thread_tcb so it can be restarted too */
+/* end: stuff userspace needs to do before switching to multi-mode */
+
+       /* get into multi mode */
+       retval = vcore_request(1);
+       if (retval)
+               printf("Fucked!\n");
+
+       printf("Proc %d requesting another vcore\n", getpid());
+       begin = read_tsc();
+       retval = vcore_request(1);
+       if (retval)
+               printf("Fucked!\n");
+       while (!core1_up)
+               cpu_relax;
+       end = read_tsc();
+       printf("Took %llu usec (%llu nsec) to receive 1 core (cold).\n",
+              udiff(begin, end), ndiff(begin, end));
+       printf("[T]:002:%llu:%llu:1:C.\n",
+              udiff(begin, end), ndiff(begin, end));
+       core1_up = FALSE;
+       udelay(2000000);
+       printf("Proc %d requesting the vcore again\n", getpid());
+       begin = read_tsc();
+       retval = vcore_request(1);
+       if (retval)
+               printf("Fucked!\n");
+       while (!core1_up)
+               cpu_relax();
+       end = read_tsc();
+       printf("Took %llu usec (%llu nsec) to receive 1 core (warm).\n",
+              udiff(begin, end), ndiff(begin, end));
+       printf("[T]:002:%llu:%llu:1:W.\n",
+              udiff(begin, end), ndiff(begin, end));
+       return 0;
+}
+
+void vcore_entry(void)
+{
+       uint32_t vcoreid = vcore_id();
+
+/* begin: stuff userspace needs to do to handle notifications */
+       struct vcore *vc = &__procinfo.vcoremap[vcoreid];
+       struct preempt_data *vcpd;
+       vcpd = &__procdata.vcore_preempt_data[vcoreid];
+       
+       /* Lets try to restart vcore0's context.  Note this doesn't do anything to
+        * set the appropriate TLS.  On x86, this will involve changing the LDT
+        * entry for this vcore to point to the TCB of the new user-thread. */
+       if (vcoreid == 0) {
+               handle_events(vcoreid);
+               set_tls_desc(core0_tls, 0);
+               assert(__vcoreid == 0); /* in case anyone uses this */
+               /* Load silly state (Floating point) too */
+               pop_user_ctx(&vcpd->uthread_ctx, vcoreid);
+               panic("should never see me!");
+       }       
+/* end: stuff userspace needs to do to handle notifications */
+
+       /* all other vcores are down here */
+       core1_up = TRUE;
+
+       while (core1_up)
+               cpu_relax();
+       printf("Proc %d's vcore %d is yielding\n", getpid(), vcoreid);
+       sys_yield(0);
+
+       while(1);
+}
+
diff --git a/tests/old/msr_nice_while.c b/tests/old/msr_nice_while.c
new file mode 100644 (file)
index 0000000..7f76718
--- /dev/null
@@ -0,0 +1,39 @@
+/* tests/msr_dumb_while.c
+ *
+ * This requests the max_vcores in the system, then just while loops in a
+ * userthread.  The pthread code will nicely yield if it detects an incoming
+ * preemption. */
+
+#include <stdlib.h>
+#include <vcore.h>
+#include <pthread.h>
+#include <rassert.h>
+#include <event.h>
+#include <uthread.h>
+
+void *while_thread(void *arg)
+{
+       while (1);
+}
+
+int main(int argc, char** argv)
+{
+       pthread_t *my_threads = malloc(sizeof(pthread_t) * max_vcores());
+
+       /* set up to receive the PREEMPT_PENDING event.  EVENT_VCORE_APPRO tells the
+        * kernel to send the msg to whichever vcore is appropriate.  Pthread code
+        * will see the preemption and yield. */
+       struct event_queue *ev_q = get_event_q();
+       ev_q->ev_flags = EVENT_IPI | EVENT_NOMSG | EVENT_VCORE_APPRO;
+       register_kevent_q(ev_q, EV_PREEMPT_PENDING);
+
+       /* actually only need one less, since the _S will be pthread 0 */
+       for (int i = 0; i < max_vcores() - 1; i++)
+               pthread_create(&my_threads[i], NULL, &while_thread, NULL);
+
+       assert(num_vcores() == max_vcores());
+       while (1);
+
+       /* should never make it here */
+       return -1;
+}
diff --git a/tests/old/msr_single_while.c b/tests/old/msr_single_while.c
new file mode 100644 (file)
index 0000000..f0f5234
--- /dev/null
@@ -0,0 +1,10 @@
+/* tests/msr_single_while.c
+ *
+ * just sits in a while loop in _S mode. */
+
+int main(int argc, char** argv)
+{
+       while(1);
+       return -1;
+}
+
diff --git a/tests/old/null.c b/tests/old/null.c
new file mode 100644 (file)
index 0000000..64f1885
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdlib.h>
+
+int main(int argc, char** argv)
+{
+       return 0;
+}
diff --git a/tests/old/proctests.c b/tests/old/proctests.c
new file mode 100644 (file)
index 0000000..e6599b3
--- /dev/null
@@ -0,0 +1,32 @@
+#include <parlib.h>
+#include <stdio.h>
+
+/* This runs a variety of process tests.  For now, it just tests single-core
+ * yielding among a bunch of processes (which it creates).  It needs the
+ * manager() to call schedule repeatedly (not panic at some weird point) for it
+ * to make progress. */
+int main(int argc, char** argv)
+{
+       int pid = sys_getpid();
+       /* first instance.  this is ghetto, since it relies on being the first proc
+        * ever.  fix this when we can pass arguments.  (TODO) */
+       #define NUM_KIDS 5
+       #define FILENAME "/bin/proctests"
+       int child_pid[NUM_KIDS];
+       if (pid == 0x1000) {
+               for (int i = 0; i < NUM_KIDS; i++)
+                       child_pid[i] = sys_proc_create(FILENAME, strlen(FILENAME), 0, 0);
+               for (int i = 0; i < NUM_KIDS; i++) {
+                       printf("U: attempting to spawn yielders (pid: %d)\n", child_pid[i]);
+                       sys_proc_run(child_pid[i]);
+               }
+       }
+       printf("Process %x, Started and yielding.\n", pid);
+       sys_yield(0);
+       printf("Process %x, Return from yield1, starting yield2.\n", pid);
+       sys_yield(0);
+       printf("Process %x, Return from yield2, starting yield3.\n", pid);
+       sys_yield(0);
+       printf("Process %x, Return from yield3, exiting.\n", pid);
+       return 0;
+}
diff --git a/tests/old/raise.c b/tests/old/raise.c
new file mode 100644 (file)
index 0000000..83f58d3
--- /dev/null
@@ -0,0 +1,77 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+volatile int count;
+
+void sighand(int sig)
+{
+       assert(SIGUSR1 == sig);
+       ++count;
+}
+
+void sigact(int sig, siginfo_t *info, void *null)
+{
+       assert(SIGUSR1 == sig);
+       assert(sig == info->si_signo);
+       ++count;
+}
+
+int main(void)
+{
+       struct sigaction sa;
+       sigemptyset(&sa.sa_mask);
+       int nr_tests = 0;
+
+       sa.sa_handler = sighand;
+       sa.sa_flags = 0;
+       nr_tests++;
+       if (sigaction(SIGUSR1, &sa, NULL) < 0) {
+               printf("first sigaction failed: %m\n");
+               exit(1);
+       }
+       if (raise(SIGUSR1) < 0) {
+               printf("first raise failed: %m\n");
+               exit(1);
+       }
+
+       sa.sa_sigaction = sigact;
+       sa.sa_flags = SA_SIGINFO;
+       nr_tests++;
+       if (sigaction(SIGUSR1, &sa, NULL) < 0) {
+               printf("second sigaction failed: %m\n");
+               exit(1);
+       }
+       if (raise(SIGUSR1) < 0) {
+               printf("second raise failed: %m\n");
+               exit(1);
+       }
+       if (count != nr_tests) {
+               printf("signal handler not called %d times\n", nr_tests);
+               exit(1);
+       }
+       printf("Passed, exiting\n");
+       exit(0);
+}
diff --git a/tests/old/slab.c b/tests/old/slab.c
new file mode 100644 (file)
index 0000000..4cd1926
--- /dev/null
@@ -0,0 +1,38 @@
+#include <slab.h>
+#include <stdio.h>
+
+static void test_single_cache(int iters, size_t size, int align, int flags,
+                              void (*ctor)(void *, size_t),
+                              void (*dtor)(void *, size_t))
+{
+       struct kmem_cache *test_cache;
+       void *objects[iters];
+       test_cache = kmem_cache_create("test_cache", size, align, flags, ctor, dtor);
+       printf("Testing Kmem Cache:\n");
+       print_kmem_cache(test_cache);
+       for (int i = 0; i < iters; i++) {
+               objects[i] = kmem_cache_alloc(test_cache, 0);
+               printf("Buffer %d addr = %p\n", i, objects[i]);
+       }
+       for (int i = 0; i < iters; i++) {
+               kmem_cache_free(test_cache, objects[i]);
+       }
+       kmem_cache_destroy(test_cache);
+       printf("\n\n\n\n");
+}
+
+void a_ctor(void *buf, size_t size)
+{
+       printf("constructin tests\n");
+}
+void a_dtor(void *buf, size_t size)
+{
+       printf("destructin tests\n");
+}
+
+int main(void)
+{
+       test_single_cache(10, 128, 512, 0, 0, 0);
+       test_single_cache(10, 128, 4, 0, a_ctor, a_dtor);
+       test_single_cache(10, 1024, 16, 0, 0, 0);
+}
diff --git a/tests/old/softint.c b/tests/old/softint.c
new file mode 100644 (file)
index 0000000..7916cbd
--- /dev/null
@@ -0,0 +1,16 @@
+// buggy program - causes an illegal software interrupt
+
+int main(int argc, char** argv)
+{
+       // this is a fake page fault.  it can only be used if the DPL is 3
+       // if the DPL = 0, this causes a general prot fault, not a PF
+       #ifdef __i386__
+       asm volatile("int $14");
+       #endif
+
+       // this is a real page fault.  volatile, so the compiler doesn't remove it
+       // this will cause a PF regardless of DPL, since it's a real PF.
+       //volatile int x = *((int*)0xc0000000);
+       return 0;
+}
+
diff --git a/tests/old/spawn.c b/tests/old/spawn.c
new file mode 100644 (file)
index 0000000..f2a46e9
--- /dev/null
@@ -0,0 +1,57 @@
+
+#include <stdio.h>
+#include <parlib.h>
+#include <unistd.h>
+
+int main(int argc, char **argv, char **envp)
+{
+       char *p_argv[] = {0, 0, 0};
+       char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
+       #define FILENAME "/bin/hello"
+       //#define FILENAME "/bin/hello-sym"
+       char filename[] = FILENAME;
+       #if 0
+       /* try some bad combos */
+       int pid = sys_proc_create("garbagexxx");
+       printf("Garbage pid result: %d\n", pid);
+
+       error_t err = sys_proc_run(2342);
+       printf("sys_proc_run(2342) error: %e\n", err);
+
+       err = sys_proc_run(-1);
+       cprintf("sys_proc_run(-1) error: %e\n", err);
+       #endif
+
+       #define NUM_KIDS 5
+       int child_pid[NUM_KIDS];
+       #if 0
+       printf("U: attempting to create hello(s)\n");
+       for (int i = 0; i < NUM_KIDS; i++)
+               child_pid[i] = sys_proc_create("roslib_hello");
+
+       for (int i = 0; i < NUM_KIDS; i++) {
+               cprintf("U: attempting to run hello (pid: %d)\n", child_pid[i]);
+               sys_proc_run(child_pid[i]);
+       }
+       #endif
+       printf("U: attempting to create and run hello\n");
+       p_argv[0] = filename;
+       printf("SPAWN, I'm pid %d, filename %s\n", getpid(), filename);
+       child_pid[0] = sys_proc_create(FILENAME, strlen(FILENAME), p_argv, p_envp);
+       if (child_pid[0] <= 0)
+               printf("Failed to create the child\n");
+       else
+               if (sys_proc_run(child_pid[0]) < 0)
+                       printf("Failed to run the child (pid %d)\n", child_pid[0]);
+
+       #if 0
+       printf("U: attempting to create and run another hello\n");
+       child_pid[1] = sys_proc_create(FILENAME, strlen(FILENAME), 0, 0);
+       if (child_pid[1] <= 0)
+               perror("");
+       else
+               if (sys_proc_run(child_pid[1]) < 0)
+                       perror("");
+       #endif
+       return 0;
+}
diff --git a/tests/old/syscall.c b/tests/old/syscall.c
new file mode 100644 (file)
index 0000000..9548798
--- /dev/null
@@ -0,0 +1,132 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <parlib.h>
+#include <event.h>
+#include <vcore.h>
+#include <rassert.h>
+#include <ros/bcq.h>
+#include <uthread.h>
+
+/* Deprecated, don't use this in any serious way */
+
+static void handle_syscall(struct event_msg *ev_msg, unsigned int ev_type);
+struct syscall sysc = {0};
+struct event_queue *ev_q;
+void ghetto_vcore_entry(void);
+
+struct schedule_ops ghetto_sched_ops = {
+       .sched_entry = ghetto_vcore_entry,
+};
+struct schedule_ops *sched_ops = &ghetto_sched_ops;
+
+int main(int argc, char** argv)
+{
+       int num_started, retval;
+       unsigned int ev_type;
+
+       /* register our syscall handler (2LS does this) */
+       ev_handlers[EV_SYSCALL] = handle_syscall;
+
+       printf("Trying to block\n");
+       /* Not doing anything else to it: no EVENT_IPI yet, etc. */
+       ev_q = get_big_event_q();
+       /* issue the diagnostic block syscall */
+       sysc.num = SYS_block;
+       sysc.arg0 = 5000;       /* 5ms */
+       sysc.ev_q = ev_q;
+       /* Trap */
+       num_started = __ros_arch_syscall((long)&sysc, 1);
+       if (!(atomic_read(&sysc.flags) & SC_DONE))
+               printf("Not done, looping!\n");
+       /* You could poll on this.  This is really ghetto, but i got rid of
+        * event_activity, whose sole purpose was to encourage spinning. */
+       while (!(atomic_read(&sysc.flags) & SC_DONE))
+               cpu_relax();
+       handle_event_q(ev_q);
+       /* by now, we should have run our handler */
+       /********************************************************/
+       /* Start MCP / IPI test */
+       printf("Switching to _M mode and testing an IPI-d ev_q\n");
+       printf("Our indirect ev_q is %08p\n", ev_q);
+
+/* begin: stuff userspace needs to do before switching to multi-mode */
+       /* Note we don't need to set up event reception for any particular kevent.
+        * The ev_q in the syscall said to send an IPI to vcore 0 which means an
+        * EV_EVENT will be sent straight to vcore0. */
+       /* Inits a thread for us, though we won't use it.  Just a hack to get into
+        * _M mode.  Note this requests one vcore for us */
+       struct uthread dummy = {0};
+       uthread_lib_init(&dummy);
+       /* Need to save our floating point state somewhere (like in the
+        * user_thread_tcb so it can be restarted too */
+       enable_notifs(0);
+/* end: stuff userspace needs to do before switching to multi-mode */
+
+       retval = vcore_request(1);
+       if (retval < 0)
+               printf("No cores granted, Rut Ro Raggy!\n");
+       /* now we're back in thread 0 on vcore 0 */
+       ev_q->ev_flags = EVENT_IPI;
+       ev_q->ev_vcore = 0;
+       sysc.u_data = (void*)1; /* using this to loop on */
+       /* issue the diagnostic blocking syscall */
+       sysc.num = SYS_block;
+       sysc.arg0 = 5000;       /* 5ms */
+       sysc.ev_q = ev_q;
+       num_started = __ros_arch_syscall((long)&sysc, 1);
+       /* have this thread "wait" */
+       if (!(atomic_read(&sysc.flags) & SC_DONE))
+               printf("Not done, looping on a local variable!\n");
+       while (sysc.u_data)
+               cpu_relax();
+       assert(atomic_read(&sysc.flags) & SC_DONE);
+       printf("Syscall unblocked, IPI broke me out of the loop.\n");
+
+       /* done */
+       put_big_event_q(ev_q);
+       printf("Syscall test exiting\n");
+       return 0;
+}
+
+static void handle_syscall(struct event_msg *ev_msg, unsigned int ev_type)
+{
+       struct syscall *my_sysc;
+       if (!ev_msg)
+               return;
+       my_sysc = ev_msg->ev_arg3;
+       printf("Handling syscall event for sysc %08p (%08p)\n",
+              my_sysc, &sysc);
+       /* our syscall should be done (we ought to check the msg pointer) */
+       if (atomic_read(&sysc.flags) & SC_DONE) 
+               printf("Syscall is done, retval: %d\n", sysc.retval);
+       else
+               printf("BUG! Syscall wasn't done!\n");
+       /* signal to thread 0 that the sysc is done, just to show this
+        * is getting done in vcore context. */
+       my_sysc->u_data = 0;
+}
+
+void ghetto_vcore_entry(void)
+{
+       uint32_t vcoreid = vcore_id();
+       static bool first_time = TRUE;
+
+/* begin: stuff userspace needs to do to handle notifications */
+
+       /* Restart vcore0's context. */
+       if (vcoreid == 0) {
+               run_current_uthread();
+               panic("should never see me!");
+       }       
+       /* unmask notifications once you can let go of the uthread_ctx and it is
+        * okay to clobber the transition stack.
+        * Check Documentation/processes.txt: 4.2.4.  In real code, you should be
+        * popping the tf of whatever user process you want (get off the x-stack) */
+       struct preempt_data *vcpd;
+       vcpd = &__procdata.vcore_preempt_data[vcoreid];
+       vcpd->notif_disabled = FALSE;
+       
+/* end: stuff userspace needs to do to handle notifications */
+       /* if you have other vcores, they'll just chill here */
+       while(1);
+}
diff --git a/tests/old/syscall_speed.c b/tests/old/syscall_speed.c
new file mode 100644 (file)
index 0000000..abadea4
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <parlib.h>
+#include <arch/arch.h>
+
+int main()
+{
+       int N = 8192;
+
+       long long tsc0 = read_tsc();
+       for(int i = 0; i < N; i++)
+               ros_syscall(SYS_null, 0, 0, 0, 0, 0, 0);
+       long long tsc1 = read_tsc();
+
+       printf("tsc0 = %lld\n",tsc0);
+       printf("syscall time = %lld\n",(tsc1-tsc0)/N);
+
+       return 0;
+}
diff --git a/tests/old/tcp_test.c b/tests/old/tcp_test.c
new file mode 100644 (file)
index 0000000..d545543
--- /dev/null
@@ -0,0 +1,108 @@
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#define BUF_SIZE 16
+#define LARGE_BUFFER_SIZE 2048
+
+/* Test program
+ *
+ * Pings the server at argv1: argv2
+ * gets a response and prints it
+ * Running in Qemu 
+ * tcp_test server_port
+ * tcp_test server_addr server_port
+ */
+
+int main(int argc, char* argv[]) {
+       struct sockaddr_in server;
+       char buf[BUF_SIZE] = "hello world";
+       char bulkdata[LARGE_BUFFER_SIZE] = "testme";
+       char recv_buf[BUF_SIZE];
+       int sockfd, n, inqemu;
+       struct hostent* host;
+
+       // ignore the host for now
+       if (argc == 2){
+               printf("in qemu client\n");
+               inqemu = 1;
+       }
+       else if (argc == 3){
+               printf("linux client\n");
+               inqemu = 0;
+       } else 
+       {
+               printf("incorrect number of parameters\n");
+       }
+       if (!inqemu){
+               host = gethostbyname(argv[1]); //hostname
+       }
+       bzero(&server, sizeof(server));
+       server.sin_family = AF_INET;
+       if (inqemu)
+               server.sin_port = htons(atoi(argv[1]));
+       else
+               server.sin_port = htons(atoi(argv[2]));
+
+
+       if (inqemu)
+               server.sin_addr.s_addr = inet_addr("10.0.0.1"); //hardcoded server 
+       else
+               // linux client, use the argument as the server address
+               memcpy(&server.sin_addr.s_addr, host->h_addr, host->h_length);
+       
+       char* printbuf = (char*)&server.sin_addr.s_addr;
+       int size = sizeof(server.sin_addr.s_addr);      
+       int i;
+       for (i=0; i<size;i++) {
+               printf("connecting to %x \n", ((char*)printbuf)[i]); 
+       }
+
+       sockfd = socket(AF_INET, SOCK_STREAM, 0);       
+       if (sockfd==-1) {
+               printf("socket error\n");
+               return -1;
+       }
+
+       printf ("tcp_test: sockfd %d \n", sockfd);
+       int socklen = sizeof(server);
+
+       // Set up a connection with the server
+       int rc;
+
+       if((rc = connect(sockfd, (struct sockaddr *)&server, sizeof(server))) < 0)
+       {
+               // testing closing a socket file
+               close(sockfd);
+               exit(-1);
+       }
+       // sending large chunk of data of 2K, more than one frame
+       // int sendsize =  sendto(sockfd, bulkdata, LARGE_BUFFER_SIZE, 0, (struct sockaddr*) &server, socklen);
+
+       fd_set readset;
+       int sendsize = send(sockfd, buf, strlen(buf), 0);
+       if (sendsize != strlen(buf)) 
+               printf("send operation failed error code %d \n", sendsize);
+       int j=0;
+       int result;
+       for (j=0; j<10; j++){
+               strcpy(recv_buf, "DEADBEEFDEADBEE");
+               // in udp_test, we can recv_from with a size of 5, because it discards the rest of the packet. In the TCP
+               // version, we need to be precise about the size of the recv, because the left over data will be displayed in the next
+               // packet.
+               if ((n = recv(sockfd, recv_buf, 14 , 0))< 0){ 
+                       printf("recv failed\n");
+               }
+               // recv_buf[n-1] = 0; //null terminate
+               printf("[OUTPUT] recv %d with length %d from result %s\n", j,n,  recv_buf);
+       }
+       while(1){;}
+       close(sockfd);
+}
diff --git a/tests/old/test_mmap_ipc.c b/tests/old/test_mmap_ipc.c
new file mode 100644 (file)
index 0000000..bff83fb
--- /dev/null
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <parlib.h>
+#include <timing.h>
+       
+int main(void)
+{
+       int pFile, *first;
+       pid_t pid;
+       pFile = open ("hello.txt", O_RDWR | O_CREAT, (mode_t)0600);
+       /* this mmap will give you a Bus Error on linux if you try to map more
+        * pages than the file contains (i think)... */
+       first = (int*)mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, pFile, 0);
+       if (first == MAP_FAILED) {
+               fprintf(stderr, "Unable to mmap the file (%d), aborting!\n", errno);
+               return -1;
+       }
+       first[0] = 3;
+       printf("the first number after initialization is %d at %08p\n", first[0],
+              first);
+       if ((pid = fork()) < 0) {
+               perror("fork error");
+               exit(1);
+       }
+       if (pid == 0) {
+               /* delay here, to avoid the race a bit */
+               udelay(1000000);
+               printf("After fork in the parent, the first number is %d\n", first[0]);
+               first[0] = 99;
+               printf("Pid 0 sees value %d at mmapped address %08p\n", first[0],
+                      first);
+       } else {
+               printf("After fork in the child, the first number is %d\n", first[0]);
+               first[0] = 11;
+               printf("Child pid %d sees value %d at mmapped address %08p\n", pid,
+                      first[0], first);
+       }
+}
diff --git a/tests/old/test_ucq.c b/tests/old/test_ucq.c
new file mode 100644 (file)
index 0000000..33ec389
--- /dev/null
@@ -0,0 +1,62 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <parlib.h>
+#include <sys/mman.h>
+#include <ucq.h>
+#include <assert.h>
+#include <arch/atomic.h>
+
+int main(int argc, char** argv)
+{
+       /* this program should only be started from the kernel for tests */
+       printf("[user] Attempting to read ucq messages from test_ucq().  "
+              "Don't call this manually.\n");
+       /* Map into a known, extremely ghetto location.  The kernel knows to look
+        * here. */
+       struct ucq *ucq = mmap((void*)USTACKTOP, PGSIZE, PROT_WRITE | PROT_READ,
+                              MAP_POPULATE, -1, 0);
+       assert((uintptr_t)ucq == USTACKTOP);
+       /* Now init it */
+       uintptr_t two_pages = (uintptr_t)mmap(0, PGSIZE * 2, PROT_WRITE | PROT_READ,
+                                             MAP_POPULATE | MAP_ANONYMOUS, -1, 0);
+       assert(two_pages);
+       ucq_init_raw(ucq, two_pages, two_pages + PGSIZE);
+       printf("[user] UCQ %08p initialized\n", ucq);
+       /* try to get a simple message */
+       struct event_msg msg;
+       /* 1: Spin til we can get a message (0 on success breaks) */
+       while (get_ucq_msg(ucq, &msg))
+               cpu_relax();
+       printf("[user] Got simple message type %d(7) with A2 %08p(0xdeadbeef)\n",
+              msg.ev_type, msg.ev_arg2);
+       /* 2: get a bunch */
+       for (int i = 0; i < 5000; i++) {
+               while (get_ucq_msg(ucq, &msg))
+                       cpu_relax();
+               assert(msg.ev_type == i);
+       }
+       printf("[user] #2 Received a bunch!  Last one was %d(4999), "
+              "extra pages %d(6, if #3 is 1000 and was blasted already)\n",
+              msg.ev_type, atomic_read(&ucq->nr_extra_pgs));
+       /* 3: test chaining */
+       while (atomic_read(&ucq->nr_extra_pgs) < 2)
+               cpu_relax();
+       printf("[user] #3 There's now a couple pages (%d), trying to receive...\n",
+              atomic_read(&ucq->nr_extra_pgs));
+       /* this assumes 1000 is enough for a couple pages */
+       for (int i = 0; i < 1000; i++) {
+               while (get_ucq_msg(ucq, &msg))
+                       cpu_relax();
+               assert(msg.ev_type == i);
+       }
+       printf("[user] Done, extra pages: %d(0)\n", atomic_read(&ucq->nr_extra_pgs));
+       int extra = 0;
+       while (!get_ucq_msg(ucq, &msg)) {
+               printf("[user] got %d extra messages in the ucq, type %d\n", ++extra,
+                      msg.ev_type);
+       }
+       printf("[user] Spinning...\n");
+       while(1);
+
+       return 0;
+}
diff --git a/tests/old/testbss.c b/tests/old/testbss.c
new file mode 100644 (file)
index 0000000..1dba334
--- /dev/null
@@ -0,0 +1,29 @@
+// test reads and writes to a large bss
+
+#include <stdint.h>
+#include <stdio.h>
+#include <rassert.h>
+
+#define ARRAYSIZE (1024*1024)
+
+uint32_t bigarray[ARRAYSIZE];
+
+int main(int argc, char** argv)
+{
+       int i;
+
+       printf("Making sure bss works right...\n");
+       for (i = 0; i < ARRAYSIZE; i++)
+               if (bigarray[i] != 0)
+                       panic("bigarray[%d] isn't cleared!\n", i);
+       for (i = 0; i < ARRAYSIZE; i++)
+               bigarray[i] = i;
+       for (i = 0; i < ARRAYSIZE; i++)
+               if (bigarray[i] != i)
+                       panic("bigarray[%d] didn't hold its value!\n", i);
+
+       printf("Yes, good.  Now doing a wild write off the end...\n");
+       bigarray[ARRAYSIZE+1024] = 0;
+       panic("SHOULD HAVE TRAPPED!!!");
+       return 0;
+}
diff --git a/tests/old/tlstest.c b/tests/old/tlstest.c
new file mode 100644 (file)
index 0000000..d5eeaf9
--- /dev/null
@@ -0,0 +1,15 @@
+#include <assert.h>
+#include <stdio.h>
+
+#define BAR0 0xdeadbeef
+volatile __thread int foo;
+volatile __thread int bar = BAR0;
+
+int main()
+{
+       printf("&foo = %p, &bar = %p\n",&foo,&bar);
+       assert(bar == BAR0);
+       bar = 0xcafebabe;
+       printf("bar = %p\n",bar);
+       return 0;
+}
diff --git a/tests/old/tsc_spitter.c b/tests/old/tsc_spitter.c
new file mode 100644 (file)
index 0000000..3686565
--- /dev/null
@@ -0,0 +1,9 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <arch/arch.h>
+
+int main(int argc, char** argv)
+{
+       printf("[T]:004:M:%llu\n", read_tsc());
+       return 0;
+}
diff --git a/tests/old/udp_test.c b/tests/old/udp_test.c
new file mode 100644 (file)
index 0000000..3116cfb
--- /dev/null
@@ -0,0 +1,103 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#define BUF_SIZE 16
+#define LARGE_BUFFER_SIZE 2048
+
+/* Test program
+ *
+ * Pings the server at argv1: argv2
+ * gets a response and prints it
+ */
+
+int main(int argc, char* argv[]) {
+       struct sockaddr_in server;
+       char buf[BUF_SIZE] = "hello world";
+       char bulkdata[LARGE_BUFFER_SIZE] = "testme";
+       char recv_buf[BUF_SIZE];
+       int sockfd, n, inqemu;
+       struct hostent* host;
+
+       // ignore the host for now
+       if (argc == 2){
+               printf("in qemu client\n");
+               inqemu = 1;
+       }
+       else if (argc == 3){
+               printf("linux client\n");
+               inqemu = 0;
+       } else 
+       {
+               printf("incorrect number of parameters\n");
+       }
+       if (!inqemu){
+               host = gethostbyname(argv[1]); //hostname
+       }
+       bzero(&server, sizeof(server));
+       server.sin_family = AF_INET;
+       if (inqemu)
+               server.sin_port = htons(atoi(argv[1]));
+       else
+               server.sin_port = htons(atoi(argv[2]));
+
+
+       if (inqemu)
+               server.sin_addr.s_addr = inet_addr("10.0.0.1"); //hardcoded server 
+       else
+               memcpy(&server.sin_addr.s_addr, host->h_addr, host->h_length);
+       
+       char* printbuf = (char*)&server.sin_addr.s_addr;
+       int size = sizeof(server.sin_addr.s_addr);      
+       int i;
+       for (i=0; i<size;i++) {
+               printf("%x", ((char*)printbuf)[i]); 
+       }
+
+       //server.sin_addr = *((struct in_addr *)host->h_addr);
+       sockfd = socket(AF_INET, SOCK_DGRAM, 0);        
+       if (sockfd==-1) {
+               printf("socket error\n");
+               return -1;
+       }
+
+       printf ("udp_test: sockfd %d \n", sockfd);
+       int socklen = sizeof(server);
+       // sending large chunk of data of 2K, more than one frame
+       // int sendsize =  sendto(sockfd, bulkdata, LARGE_BUFFER_SIZE, 0, (struct sockaddr*) &server, socklen);
+
+       // sending a large chunk of data but fitting in one packet
+       //int sendsize =  sendto(sockfd, bulkdata, 500, 0, (struct sockaddr*) &server, socklen);
+       fd_set readset;
+       int sendsize = sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr*) &server, socklen);
+       printf("sendto returns %d, errno %d\n", sendsize, errno);
+       //assume BUF_SIZE is larger than the packet.. so we will get to see what actually comes back..
+       int j=0;
+       int result;
+       for (j=0; j<10; j++){
+               strcpy(recv_buf, "DEADBEEFDEADBEE");
+               // select before a blocking receive
+               do {
+                       FD_ZERO(&readset);
+                       FD_SET(sockfd, &readset);
+                       result = select(sockfd + 1, &readset, NULL, NULL, NULL);
+                       printf("select result %d \n", result);
+                       printf("readset %d \n", FD_ISSET(sockfd, &readset));
+               } while (result == -1 && errno == EINTR);
+               // configure recvfrom not to block when there is 
+
+               if (((n = recvfrom(sockfd, recv_buf, 5, 0, (struct sockaddr*) &server, &socklen))< 0)){ // should discard if it is udp..
+                       printf("recv failed\n");
+               }
+               recv_buf[n-1] = 0; //null terminate
+               printf("[OUTPUT] recv %d with length %d from result %s\n", j,n,  recv_buf);
+       }
+       while(1){;}
+       close(sockfd);
+}
diff --git a/tests/old/user_tests.h b/tests/old/user_tests.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/old/vvadd.c b/tests/old/vvadd.c
new file mode 100644 (file)
index 0000000..579c9be
--- /dev/null
@@ -0,0 +1,26 @@
+#include <assert.h>
+#include <stdio.h>
+
+int main()
+{
+       #define N 12345
+       double x[N];
+       double y[N];
+       double z[N];
+
+       for(int i = 0; i < N; i++)
+       {
+               x[i] = (double)i;
+               y[i] = (double)(2*i);
+       }
+
+       for(int i = 0; i < N; i++)
+               z[i] = x[i]+y[i];
+
+       for(int i = 0; i < N; i++)
+               assert((int)z[i] == 3*i);
+
+       printf("vvadd works!\n");
+
+       return 0;
+}
index e303990..f638bf5 100644 (file)
@@ -4,7 +4,7 @@ OPENMP_TESTS_CFLAGS += $(CFLAGS_TESTS) \
                      -fopenmp \
                      -I$(XCC_TARGET_ROOT)/sys-include/openmp
 
-ALL_OPENMP_TEST_FILES = $(shell ls $(OPENMP_TESTS_DIR)/*.c)
+ALL_OPENMP_TEST_FILES := $(wildcard $(OPENMP_TESTS_DIR)/*.c)
 
 OPENMP_TESTS_LDLIBS := 
 
diff --git a/tests/openmp/old/omp_hello.c b/tests/openmp/old/omp_hello.c
new file mode 100644 (file)
index 0000000..07eccd7
--- /dev/null
@@ -0,0 +1,31 @@
+#include <sys/sysinfo.h>
+#include <omp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <vcore.h>
+
+int main (int argc, char *argv[]) 
+{
+  int nthreads, tid;
+  printf("get_nprocs: %d\n", get_nprocs());
+  printf("SC_NPROCESSORS_ONLN: %d\n", sysconf (_SC_NPROCESSORS_ONLN));
+  printf("max num vcores: %d\n", max_vcores());
+
+/* Fork a team of threads giving them their own copies of variables */
+#pragma omp parallel private(nthreads, tid)
+  {
+
+  /* Obtain thread number */
+  tid = omp_get_thread_num();
+  printf("Hello World from thread = %d\n", tid);
+
+  /* Only master thread does this */
+  if (tid == 0) 
+    {
+    nthreads = omp_get_num_threads();
+    printf("Number of threads = %d\n", nthreads);
+    }
+
+  }  /* All threads join master thread and disband */
+
+}
diff --git a/tests/openmp/omp_hello.c b/tests/openmp/omp_hello.c
deleted file mode 100644 (file)
index 07eccd7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <sys/sysinfo.h>
-#include <omp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <vcore.h>
-
-int main (int argc, char *argv[]) 
-{
-  int nthreads, tid;
-  printf("get_nprocs: %d\n", get_nprocs());
-  printf("SC_NPROCESSORS_ONLN: %d\n", sysconf (_SC_NPROCESSORS_ONLN));
-  printf("max num vcores: %d\n", max_vcores());
-
-/* Fork a team of threads giving them their own copies of variables */
-#pragma omp parallel private(nthreads, tid)
-  {
-
-  /* Obtain thread number */
-  tid = omp_get_thread_num();
-  printf("Hello World from thread = %d\n", tid);
-
-  /* Only master thread does this */
-  if (tid == 0) 
-    {
-    nthreads = omp_get_num_threads();
-    printf("Number of threads = %d\n", nthreads);
-    }
-
-  }  /* All threads join master thread and disband */
-
-}
diff --git a/tests/proctests.c b/tests/proctests.c
deleted file mode 100644 (file)
index e6599b3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <parlib.h>
-#include <stdio.h>
-
-/* This runs a variety of process tests.  For now, it just tests single-core
- * yielding among a bunch of processes (which it creates).  It needs the
- * manager() to call schedule repeatedly (not panic at some weird point) for it
- * to make progress. */
-int main(int argc, char** argv)
-{
-       int pid = sys_getpid();
-       /* first instance.  this is ghetto, since it relies on being the first proc
-        * ever.  fix this when we can pass arguments.  (TODO) */
-       #define NUM_KIDS 5
-       #define FILENAME "/bin/proctests"
-       int child_pid[NUM_KIDS];
-       if (pid == 0x1000) {
-               for (int i = 0; i < NUM_KIDS; i++)
-                       child_pid[i] = sys_proc_create(FILENAME, strlen(FILENAME), 0, 0);
-               for (int i = 0; i < NUM_KIDS; i++) {
-                       printf("U: attempting to spawn yielders (pid: %d)\n", child_pid[i]);
-                       sys_proc_run(child_pid[i]);
-               }
-       }
-       printf("Process %x, Started and yielding.\n", pid);
-       sys_yield(0);
-       printf("Process %x, Return from yield1, starting yield2.\n", pid);
-       sys_yield(0);
-       printf("Process %x, Return from yield2, starting yield3.\n", pid);
-       sys_yield(0);
-       printf("Process %x, Return from yield3, exiting.\n", pid);
-       return 0;
-}
diff --git a/tests/raise.c b/tests/raise.c
deleted file mode 100644 (file)
index 83f58d3..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include <errno.h>
-#include <error.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
-volatile int count;
-
-void sighand(int sig)
-{
-       assert(SIGUSR1 == sig);
-       ++count;
-}
-
-void sigact(int sig, siginfo_t *info, void *null)
-{
-       assert(SIGUSR1 == sig);
-       assert(sig == info->si_signo);
-       ++count;
-}
-
-int main(void)
-{
-       struct sigaction sa;
-       sigemptyset(&sa.sa_mask);
-       int nr_tests = 0;
-
-       sa.sa_handler = sighand;
-       sa.sa_flags = 0;
-       nr_tests++;
-       if (sigaction(SIGUSR1, &sa, NULL) < 0) {
-               printf("first sigaction failed: %m\n");
-               exit(1);
-       }
-       if (raise(SIGUSR1) < 0) {
-               printf("first raise failed: %m\n");
-               exit(1);
-       }
-
-       sa.sa_sigaction = sigact;
-       sa.sa_flags = SA_SIGINFO;
-       nr_tests++;
-       if (sigaction(SIGUSR1, &sa, NULL) < 0) {
-               printf("second sigaction failed: %m\n");
-               exit(1);
-       }
-       if (raise(SIGUSR1) < 0) {
-               printf("second raise failed: %m\n");
-               exit(1);
-       }
-       if (count != nr_tests) {
-               printf("signal handler not called %d times\n", nr_tests);
-               exit(1);
-       }
-       printf("Passed, exiting\n");
-       exit(0);
-}
diff --git a/tests/slab.c b/tests/slab.c
deleted file mode 100644 (file)
index 4cd1926..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <slab.h>
-#include <stdio.h>
-
-static void test_single_cache(int iters, size_t size, int align, int flags,
-                              void (*ctor)(void *, size_t),
-                              void (*dtor)(void *, size_t))
-{
-       struct kmem_cache *test_cache;
-       void *objects[iters];
-       test_cache = kmem_cache_create("test_cache", size, align, flags, ctor, dtor);
-       printf("Testing Kmem Cache:\n");
-       print_kmem_cache(test_cache);
-       for (int i = 0; i < iters; i++) {
-               objects[i] = kmem_cache_alloc(test_cache, 0);
-               printf("Buffer %d addr = %p\n", i, objects[i]);
-       }
-       for (int i = 0; i < iters; i++) {
-               kmem_cache_free(test_cache, objects[i]);
-       }
-       kmem_cache_destroy(test_cache);
-       printf("\n\n\n\n");
-}
-
-void a_ctor(void *buf, size_t size)
-{
-       printf("constructin tests\n");
-}
-void a_dtor(void *buf, size_t size)
-{
-       printf("destructin tests\n");
-}
-
-int main(void)
-{
-       test_single_cache(10, 128, 512, 0, 0, 0);
-       test_single_cache(10, 128, 4, 0, a_ctor, a_dtor);
-       test_single_cache(10, 1024, 16, 0, 0, 0);
-}
diff --git a/tests/softint.c b/tests/softint.c
deleted file mode 100644 (file)
index 7916cbd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// buggy program - causes an illegal software interrupt
-
-int main(int argc, char** argv)
-{
-       // this is a fake page fault.  it can only be used if the DPL is 3
-       // if the DPL = 0, this causes a general prot fault, not a PF
-       #ifdef __i386__
-       asm volatile("int $14");
-       #endif
-
-       // this is a real page fault.  volatile, so the compiler doesn't remove it
-       // this will cause a PF regardless of DPL, since it's a real PF.
-       //volatile int x = *((int*)0xc0000000);
-       return 0;
-}
-
diff --git a/tests/spawn.c b/tests/spawn.c
deleted file mode 100644 (file)
index f2a46e9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-
-#include <stdio.h>
-#include <parlib.h>
-#include <unistd.h>
-
-int main(int argc, char **argv, char **envp)
-{
-       char *p_argv[] = {0, 0, 0};
-       char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
-       #define FILENAME "/bin/hello"
-       //#define FILENAME "/bin/hello-sym"
-       char filename[] = FILENAME;
-       #if 0
-       /* try some bad combos */
-       int pid = sys_proc_create("garbagexxx");
-       printf("Garbage pid result: %d\n", pid);
-
-       error_t err = sys_proc_run(2342);
-       printf("sys_proc_run(2342) error: %e\n", err);
-
-       err = sys_proc_run(-1);
-       cprintf("sys_proc_run(-1) error: %e\n", err);
-       #endif
-
-       #define NUM_KIDS 5
-       int child_pid[NUM_KIDS];
-       #if 0
-       printf("U: attempting to create hello(s)\n");
-       for (int i = 0; i < NUM_KIDS; i++)
-               child_pid[i] = sys_proc_create("roslib_hello");
-
-       for (int i = 0; i < NUM_KIDS; i++) {
-               cprintf("U: attempting to run hello (pid: %d)\n", child_pid[i]);
-               sys_proc_run(child_pid[i]);
-       }
-       #endif
-       printf("U: attempting to create and run hello\n");
-       p_argv[0] = filename;
-       printf("SPAWN, I'm pid %d, filename %s\n", getpid(), filename);
-       child_pid[0] = sys_proc_create(FILENAME, strlen(FILENAME), p_argv, p_envp);
-       if (child_pid[0] <= 0)
-               printf("Failed to create the child\n");
-       else
-               if (sys_proc_run(child_pid[0]) < 0)
-                       printf("Failed to run the child (pid %d)\n", child_pid[0]);
-
-       #if 0
-       printf("U: attempting to create and run another hello\n");
-       child_pid[1] = sys_proc_create(FILENAME, strlen(FILENAME), 0, 0);
-       if (child_pid[1] <= 0)
-               perror("");
-       else
-               if (sys_proc_run(child_pid[1]) < 0)
-                       perror("");
-       #endif
-       return 0;
-}
diff --git a/tests/syscall.c b/tests/syscall.c
deleted file mode 100644 (file)
index 9548798..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <parlib.h>
-#include <event.h>
-#include <vcore.h>
-#include <rassert.h>
-#include <ros/bcq.h>
-#include <uthread.h>
-
-/* Deprecated, don't use this in any serious way */
-
-static void handle_syscall(struct event_msg *ev_msg, unsigned int ev_type);
-struct syscall sysc = {0};
-struct event_queue *ev_q;
-void ghetto_vcore_entry(void);
-
-struct schedule_ops ghetto_sched_ops = {
-       .sched_entry = ghetto_vcore_entry,
-};
-struct schedule_ops *sched_ops = &ghetto_sched_ops;
-
-int main(int argc, char** argv)
-{
-       int num_started, retval;
-       unsigned int ev_type;
-
-       /* register our syscall handler (2LS does this) */
-       ev_handlers[EV_SYSCALL] = handle_syscall;
-
-       printf("Trying to block\n");
-       /* Not doing anything else to it: no EVENT_IPI yet, etc. */
-       ev_q = get_big_event_q();
-       /* issue the diagnostic block syscall */
-       sysc.num = SYS_block;
-       sysc.arg0 = 5000;       /* 5ms */
-       sysc.ev_q = ev_q;
-       /* Trap */
-       num_started = __ros_arch_syscall((long)&sysc, 1);
-       if (!(atomic_read(&sysc.flags) & SC_DONE))
-               printf("Not done, looping!\n");
-       /* You could poll on this.  This is really ghetto, but i got rid of
-        * event_activity, whose sole purpose was to encourage spinning. */
-       while (!(atomic_read(&sysc.flags) & SC_DONE))
-               cpu_relax();
-       handle_event_q(ev_q);
-       /* by now, we should have run our handler */
-       /********************************************************/
-       /* Start MCP / IPI test */
-       printf("Switching to _M mode and testing an IPI-d ev_q\n");
-       printf("Our indirect ev_q is %08p\n", ev_q);
-
-/* begin: stuff userspace needs to do before switching to multi-mode */
-       /* Note we don't need to set up event reception for any particular kevent.
-        * The ev_q in the syscall said to send an IPI to vcore 0 which means an
-        * EV_EVENT will be sent straight to vcore0. */
-       /* Inits a thread for us, though we won't use it.  Just a hack to get into
-        * _M mode.  Note this requests one vcore for us */
-       struct uthread dummy = {0};
-       uthread_lib_init(&dummy);
-       /* Need to save our floating point state somewhere (like in the
-        * user_thread_tcb so it can be restarted too */
-       enable_notifs(0);
-/* end: stuff userspace needs to do before switching to multi-mode */
-
-       retval = vcore_request(1);
-       if (retval < 0)
-               printf("No cores granted, Rut Ro Raggy!\n");
-       /* now we're back in thread 0 on vcore 0 */
-       ev_q->ev_flags = EVENT_IPI;
-       ev_q->ev_vcore = 0;
-       sysc.u_data = (void*)1; /* using this to loop on */
-       /* issue the diagnostic blocking syscall */
-       sysc.num = SYS_block;
-       sysc.arg0 = 5000;       /* 5ms */
-       sysc.ev_q = ev_q;
-       num_started = __ros_arch_syscall((long)&sysc, 1);
-       /* have this thread "wait" */
-       if (!(atomic_read(&sysc.flags) & SC_DONE))
-               printf("Not done, looping on a local variable!\n");
-       while (sysc.u_data)
-               cpu_relax();
-       assert(atomic_read(&sysc.flags) & SC_DONE);
-       printf("Syscall unblocked, IPI broke me out of the loop.\n");
-
-       /* done */
-       put_big_event_q(ev_q);
-       printf("Syscall test exiting\n");
-       return 0;
-}
-
-static void handle_syscall(struct event_msg *ev_msg, unsigned int ev_type)
-{
-       struct syscall *my_sysc;
-       if (!ev_msg)
-               return;
-       my_sysc = ev_msg->ev_arg3;
-       printf("Handling syscall event for sysc %08p (%08p)\n",
-              my_sysc, &sysc);
-       /* our syscall should be done (we ought to check the msg pointer) */
-       if (atomic_read(&sysc.flags) & SC_DONE) 
-               printf("Syscall is done, retval: %d\n", sysc.retval);
-       else
-               printf("BUG! Syscall wasn't done!\n");
-       /* signal to thread 0 that the sysc is done, just to show this
-        * is getting done in vcore context. */
-       my_sysc->u_data = 0;
-}
-
-void ghetto_vcore_entry(void)
-{
-       uint32_t vcoreid = vcore_id();
-       static bool first_time = TRUE;
-
-/* begin: stuff userspace needs to do to handle notifications */
-
-       /* Restart vcore0's context. */
-       if (vcoreid == 0) {
-               run_current_uthread();
-               panic("should never see me!");
-       }       
-       /* unmask notifications once you can let go of the uthread_ctx and it is
-        * okay to clobber the transition stack.
-        * Check Documentation/processes.txt: 4.2.4.  In real code, you should be
-        * popping the tf of whatever user process you want (get off the x-stack) */
-       struct preempt_data *vcpd;
-       vcpd = &__procdata.vcore_preempt_data[vcoreid];
-       vcpd->notif_disabled = FALSE;
-       
-/* end: stuff userspace needs to do to handle notifications */
-       /* if you have other vcores, they'll just chill here */
-       while(1);
-}
diff --git a/tests/syscall_speed.c b/tests/syscall_speed.c
deleted file mode 100644 (file)
index abadea4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-#include <parlib.h>
-#include <arch/arch.h>
-
-int main()
-{
-       int N = 8192;
-
-       long long tsc0 = read_tsc();
-       for(int i = 0; i < N; i++)
-               ros_syscall(SYS_null, 0, 0, 0, 0, 0, 0);
-       long long tsc1 = read_tsc();
-
-       printf("tsc0 = %lld\n",tsc0);
-       printf("syscall time = %lld\n",(tsc1-tsc0)/N);
-
-       return 0;
-}
diff --git a/tests/tcp_test.c b/tests/tcp_test.c
deleted file mode 100644 (file)
index d545543..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#define BUF_SIZE 16
-#define LARGE_BUFFER_SIZE 2048
-
-/* Test program
- *
- * Pings the server at argv1: argv2
- * gets a response and prints it
- * Running in Qemu 
- * tcp_test server_port
- * tcp_test server_addr server_port
- */
-
-int main(int argc, char* argv[]) {
-       struct sockaddr_in server;
-       char buf[BUF_SIZE] = "hello world";
-       char bulkdata[LARGE_BUFFER_SIZE] = "testme";
-       char recv_buf[BUF_SIZE];
-       int sockfd, n, inqemu;
-       struct hostent* host;
-
-       // ignore the host for now
-       if (argc == 2){
-               printf("in qemu client\n");
-               inqemu = 1;
-       }
-       else if (argc == 3){
-               printf("linux client\n");
-               inqemu = 0;
-       } else 
-       {
-               printf("incorrect number of parameters\n");
-       }
-       if (!inqemu){
-               host = gethostbyname(argv[1]); //hostname
-       }
-       bzero(&server, sizeof(server));
-       server.sin_family = AF_INET;
-       if (inqemu)
-               server.sin_port = htons(atoi(argv[1]));
-       else
-               server.sin_port = htons(atoi(argv[2]));
-
-
-       if (inqemu)
-               server.sin_addr.s_addr = inet_addr("10.0.0.1"); //hardcoded server 
-       else
-               // linux client, use the argument as the server address
-               memcpy(&server.sin_addr.s_addr, host->h_addr, host->h_length);
-       
-       char* printbuf = (char*)&server.sin_addr.s_addr;
-       int size = sizeof(server.sin_addr.s_addr);      
-       int i;
-       for (i=0; i<size;i++) {
-               printf("connecting to %x \n", ((char*)printbuf)[i]); 
-       }
-
-       sockfd = socket(AF_INET, SOCK_STREAM, 0);       
-       if (sockfd==-1) {
-               printf("socket error\n");
-               return -1;
-       }
-
-       printf ("tcp_test: sockfd %d \n", sockfd);
-       int socklen = sizeof(server);
-
-       // Set up a connection with the server
-       int rc;
-
-       if((rc = connect(sockfd, (struct sockaddr *)&server, sizeof(server))) < 0)
-       {
-               // testing closing a socket file
-               close(sockfd);
-               exit(-1);
-       }
-       // sending large chunk of data of 2K, more than one frame
-       // int sendsize =  sendto(sockfd, bulkdata, LARGE_BUFFER_SIZE, 0, (struct sockaddr*) &server, socklen);
-
-       fd_set readset;
-       int sendsize = send(sockfd, buf, strlen(buf), 0);
-       if (sendsize != strlen(buf)) 
-               printf("send operation failed error code %d \n", sendsize);
-       int j=0;
-       int result;
-       for (j=0; j<10; j++){
-               strcpy(recv_buf, "DEADBEEFDEADBEE");
-               // in udp_test, we can recv_from with a size of 5, because it discards the rest of the packet. In the TCP
-               // version, we need to be precise about the size of the recv, because the left over data will be displayed in the next
-               // packet.
-               if ((n = recv(sockfd, recv_buf, 14 , 0))< 0){ 
-                       printf("recv failed\n");
-               }
-               // recv_buf[n-1] = 0; //null terminate
-               printf("[OUTPUT] recv %d with length %d from result %s\n", j,n,  recv_buf);
-       }
-       while(1){;}
-       close(sockfd);
-}
diff --git a/tests/test_mmap_ipc.c b/tests/test_mmap_ipc.c
deleted file mode 100644 (file)
index bff83fb..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <parlib.h>
-#include <timing.h>
-       
-int main(void)
-{
-       int pFile, *first;
-       pid_t pid;
-       pFile = open ("hello.txt", O_RDWR | O_CREAT, (mode_t)0600);
-       /* this mmap will give you a Bus Error on linux if you try to map more
-        * pages than the file contains (i think)... */
-       first = (int*)mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, pFile, 0);
-       if (first == MAP_FAILED) {
-               fprintf(stderr, "Unable to mmap the file (%d), aborting!\n", errno);
-               return -1;
-       }
-       first[0] = 3;
-       printf("the first number after initialization is %d at %08p\n", first[0],
-              first);
-       if ((pid = fork()) < 0) {
-               perror("fork error");
-               exit(1);
-       }
-       if (pid == 0) {
-               /* delay here, to avoid the race a bit */
-               udelay(1000000);
-               printf("After fork in the parent, the first number is %d\n", first[0]);
-               first[0] = 99;
-               printf("Pid 0 sees value %d at mmapped address %08p\n", first[0],
-                      first);
-       } else {
-               printf("After fork in the child, the first number is %d\n", first[0]);
-               first[0] = 11;
-               printf("Child pid %d sees value %d at mmapped address %08p\n", pid,
-                      first[0], first);
-       }
-}
diff --git a/tests/testbss.c b/tests/testbss.c
deleted file mode 100644 (file)
index 1dba334..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// test reads and writes to a large bss
-
-#include <stdint.h>
-#include <stdio.h>
-#include <rassert.h>
-
-#define ARRAYSIZE (1024*1024)
-
-uint32_t bigarray[ARRAYSIZE];
-
-int main(int argc, char** argv)
-{
-       int i;
-
-       printf("Making sure bss works right...\n");
-       for (i = 0; i < ARRAYSIZE; i++)
-               if (bigarray[i] != 0)
-                       panic("bigarray[%d] isn't cleared!\n", i);
-       for (i = 0; i < ARRAYSIZE; i++)
-               bigarray[i] = i;
-       for (i = 0; i < ARRAYSIZE; i++)
-               if (bigarray[i] != i)
-                       panic("bigarray[%d] didn't hold its value!\n", i);
-
-       printf("Yes, good.  Now doing a wild write off the end...\n");
-       bigarray[ARRAYSIZE+1024] = 0;
-       panic("SHOULD HAVE TRAPPED!!!");
-       return 0;
-}
diff --git a/tests/tlstest.c b/tests/tlstest.c
deleted file mode 100644 (file)
index d5eeaf9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-
-#define BAR0 0xdeadbeef
-volatile __thread int foo;
-volatile __thread int bar = BAR0;
-
-int main()
-{
-       printf("&foo = %p, &bar = %p\n",&foo,&bar);
-       assert(bar == BAR0);
-       bar = 0xcafebabe;
-       printf("bar = %p\n",bar);
-       return 0;
-}
diff --git a/tests/tsc_spitter.c b/tests/tsc_spitter.c
deleted file mode 100644 (file)
index 3686565..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <arch/arch.h>
-
-int main(int argc, char** argv)
-{
-       printf("[T]:004:M:%llu\n", read_tsc());
-       return 0;
-}
diff --git a/tests/ucq.c b/tests/ucq.c
deleted file mode 100644 (file)
index 33ec389..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <parlib.h>
-#include <sys/mman.h>
-#include <ucq.h>
-#include <assert.h>
-#include <arch/atomic.h>
-
-int main(int argc, char** argv)
-{
-       /* this program should only be started from the kernel for tests */
-       printf("[user] Attempting to read ucq messages from test_ucq().  "
-              "Don't call this manually.\n");
-       /* Map into a known, extremely ghetto location.  The kernel knows to look
-        * here. */
-       struct ucq *ucq = mmap((void*)USTACKTOP, PGSIZE, PROT_WRITE | PROT_READ,
-                              MAP_POPULATE, -1, 0);
-       assert((uintptr_t)ucq == USTACKTOP);
-       /* Now init it */
-       uintptr_t two_pages = (uintptr_t)mmap(0, PGSIZE * 2, PROT_WRITE | PROT_READ,
-                                             MAP_POPULATE | MAP_ANONYMOUS, -1, 0);
-       assert(two_pages);
-       ucq_init_raw(ucq, two_pages, two_pages + PGSIZE);
-       printf("[user] UCQ %08p initialized\n", ucq);
-       /* try to get a simple message */
-       struct event_msg msg;
-       /* 1: Spin til we can get a message (0 on success breaks) */
-       while (get_ucq_msg(ucq, &msg))
-               cpu_relax();
-       printf("[user] Got simple message type %d(7) with A2 %08p(0xdeadbeef)\n",
-              msg.ev_type, msg.ev_arg2);
-       /* 2: get a bunch */
-       for (int i = 0; i < 5000; i++) {
-               while (get_ucq_msg(ucq, &msg))
-                       cpu_relax();
-               assert(msg.ev_type == i);
-       }
-       printf("[user] #2 Received a bunch!  Last one was %d(4999), "
-              "extra pages %d(6, if #3 is 1000 and was blasted already)\n",
-              msg.ev_type, atomic_read(&ucq->nr_extra_pgs));
-       /* 3: test chaining */
-       while (atomic_read(&ucq->nr_extra_pgs) < 2)
-               cpu_relax();
-       printf("[user] #3 There's now a couple pages (%d), trying to receive...\n",
-              atomic_read(&ucq->nr_extra_pgs));
-       /* this assumes 1000 is enough for a couple pages */
-       for (int i = 0; i < 1000; i++) {
-               while (get_ucq_msg(ucq, &msg))
-                       cpu_relax();
-               assert(msg.ev_type == i);
-       }
-       printf("[user] Done, extra pages: %d(0)\n", atomic_read(&ucq->nr_extra_pgs));
-       int extra = 0;
-       while (!get_ucq_msg(ucq, &msg)) {
-               printf("[user] got %d extra messages in the ucq, type %d\n", ++extra,
-                      msg.ev_type);
-       }
-       printf("[user] Spinning...\n");
-       while(1);
-
-       return 0;
-}
diff --git a/tests/udp_test.c b/tests/udp_test.c
deleted file mode 100644 (file)
index 3116cfb..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#define BUF_SIZE 16
-#define LARGE_BUFFER_SIZE 2048
-
-/* Test program
- *
- * Pings the server at argv1: argv2
- * gets a response and prints it
- */
-
-int main(int argc, char* argv[]) {
-       struct sockaddr_in server;
-       char buf[BUF_SIZE] = "hello world";
-       char bulkdata[LARGE_BUFFER_SIZE] = "testme";
-       char recv_buf[BUF_SIZE];
-       int sockfd, n, inqemu;
-       struct hostent* host;
-
-       // ignore the host for now
-       if (argc == 2){
-               printf("in qemu client\n");
-               inqemu = 1;
-       }
-       else if (argc == 3){
-               printf("linux client\n");
-               inqemu = 0;
-       } else 
-       {
-               printf("incorrect number of parameters\n");
-       }
-       if (!inqemu){
-               host = gethostbyname(argv[1]); //hostname
-       }
-       bzero(&server, sizeof(server));
-       server.sin_family = AF_INET;
-       if (inqemu)
-               server.sin_port = htons(atoi(argv[1]));
-       else
-               server.sin_port = htons(atoi(argv[2]));
-
-
-       if (inqemu)
-               server.sin_addr.s_addr = inet_addr("10.0.0.1"); //hardcoded server 
-       else
-               memcpy(&server.sin_addr.s_addr, host->h_addr, host->h_length);
-       
-       char* printbuf = (char*)&server.sin_addr.s_addr;
-       int size = sizeof(server.sin_addr.s_addr);      
-       int i;
-       for (i=0; i<size;i++) {
-               printf("%x", ((char*)printbuf)[i]); 
-       }
-
-       //server.sin_addr = *((struct in_addr *)host->h_addr);
-       sockfd = socket(AF_INET, SOCK_DGRAM, 0);        
-       if (sockfd==-1) {
-               printf("socket error\n");
-               return -1;
-       }
-
-       printf ("udp_test: sockfd %d \n", sockfd);
-       int socklen = sizeof(server);
-       // sending large chunk of data of 2K, more than one frame
-       // int sendsize =  sendto(sockfd, bulkdata, LARGE_BUFFER_SIZE, 0, (struct sockaddr*) &server, socklen);
-
-       // sending a large chunk of data but fitting in one packet
-       //int sendsize =  sendto(sockfd, bulkdata, 500, 0, (struct sockaddr*) &server, socklen);
-       fd_set readset;
-       int sendsize = sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr*) &server, socklen);
-       printf("sendto returns %d, errno %d\n", sendsize, errno);
-       //assume BUF_SIZE is larger than the packet.. so we will get to see what actually comes back..
-       int j=0;
-       int result;
-       for (j=0; j<10; j++){
-               strcpy(recv_buf, "DEADBEEFDEADBEE");
-               // select before a blocking receive
-               do {
-                       FD_ZERO(&readset);
-                       FD_SET(sockfd, &readset);
-                       result = select(sockfd + 1, &readset, NULL, NULL, NULL);
-                       printf("select result %d \n", result);
-                       printf("readset %d \n", FD_ISSET(sockfd, &readset));
-               } while (result == -1 && errno == EINTR);
-               // configure recvfrom not to block when there is 
-
-               if (((n = recvfrom(sockfd, recv_buf, 5, 0, (struct sockaddr*) &server, &socklen))< 0)){ // should discard if it is udp..
-                       printf("recv failed\n");
-               }
-               recv_buf[n-1] = 0; //null terminate
-               printf("[OUTPUT] recv %d with length %d from result %s\n", j,n,  recv_buf);
-       }
-       while(1){;}
-       close(sockfd);
-}
diff --git a/tests/user_tests.h b/tests/user_tests.h
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tests/vvadd.c b/tests/vvadd.c
deleted file mode 100644 (file)
index 579c9be..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-
-int main()
-{
-       #define N 12345
-       double x[N];
-       double y[N];
-       double z[N];
-
-       for(int i = 0; i < N; i++)
-       {
-               x[i] = (double)i;
-               y[i] = (double)(2*i);
-       }
-
-       for(int i = 0; i < N; i++)
-               z[i] = x[i]+y[i];
-
-       for(int i = 0; i < N; i++)
-               assert((int)z[i] == 3*i);
-
-       printf("vvadd works!\n");
-
-       return 0;
-}