prof: samples userspace PCs
[akaros.git] / kern / src / manager.c
index 20111b9..4d6f075 100644 (file)
@@ -22,7 +22,7 @@
 #include <process.h>
 #include <schedule.h>
 #include <syscall.h>
-#include <testing.h>
+#include <ktest.h>
 #include <kfs.h>
 #include <stdio.h>
 #include <time.h>
  */
 void manager(void)
 {
-       #ifndef DEVELOPER_NAME
-               #define DEVELOPER_NAME brho
-       #endif
-
        // LoL
        #define PASTE(s1,s2) s1 ## s2
        #define MANAGER_FUNC(dev) PASTE(manager_,dev)
 
+       #if !defined(DEVELOPER_NAME) && \
+           (defined(CONFIG_KERNEL_POSTBOOT_TESTING) || \
+            defined(CONFIG_USERSPACE_TESTING))
+               #define DEVELOPER_NAME jenkins
+       #endif
+
+       #ifndef DEVELOPER_NAME
+               #define DEVELOPER_NAME brho
+       #endif
+
        void MANAGER_FUNC(DEVELOPER_NAME)(void);
        MANAGER_FUNC(DEVELOPER_NAME)();
 }
@@ -115,11 +121,12 @@ void manager_brho(void)
        if (first) {    
                printk("*** IRQs must be enabled for input emergency codes ***\n");
                #ifdef CONFIG_X86
-               printk("*** Hit ctrl-g or shift-g to enter the monitor. ***\n");
+               printk("*** Hit ctrl-g to enter the monitor. ***\n");
                printk("*** Hit ctrl-q to force-enter the monitor. ***\n");
                printk("*** Hit ctrl-b for a backtrace of core 0 ***\n");
                #else
-               printk("*** Hit shift-g to enter the monitor. ***\n");
+               printk("*** Hit ctrl-g to enter the monitor. ***\n");
+               #warning "***** ctrl-g untested on riscv, check k/a/r/trap.c *****"
                #endif
                first = FALSE;
        }
@@ -220,6 +227,36 @@ void manager_brho(void)
 #endif
 }
 
+void manager_jenkins()
+{ 
+       #ifdef CONFIG_KERNEL_TESTING
+               printk("<-- BEGIN_KERNEL_TESTS -->\n");
+               run_registered_ktest_suites();
+               printk("<-- END_KERNEL_TESTS -->\n");
+       #endif
+
+       // Run userspace tests (from config specified path).
+       #ifdef CONFIG_USERSPACE_TESTING
+       if (strlen(CONFIG_USERSPACE_TESTING_SCRIPT) != 0) {
+               char exec[] = "/bin/ash";
+               char *p_argv[] = {exec, CONFIG_USERSPACE_TESTING_SCRIPT, 0};
+               char *p_envp[] = {"LD_LIBRARY_PATH=/lib", 0};
+
+               struct file *program = do_file_open(exec, 0, 0);
+               struct proc *p = proc_create(program, p_argv, p_envp);
+               proc_wakeup(p);
+               proc_decref(p); /* let go of the reference created in proc_create() */
+               kref_put(&program->f_kref);
+               run_scheduler();
+           // Need a way to wait for p to finish
+       } else {
+               printk("No user-space launcher file specified.\n");
+       }
+       #endif
+       smp_idle();
+       assert(0);
+}
+
 void manager_klueska()
 {
        static struct proc *envs[256];