Home | History | Annotate | Download | only in solaris
      1 /* Scalar test for new spawn syscall available on Solaris 11. */
      2 
      3 #include "scalar.h"
      4 
      5 #include <sys/spawn_impl.h>
      6 
      7 __attribute__((noinline))
      8 static void sys_spawn(void)
      9 {
     10    GO(SYS_spawn, "5s 7m");
     11    SY(SYS_spawn, x0 + 1, x0 + 1, x0 - 1, x0 + 1, x0 - 1); FAIL;
     12 }
     13 
     14 __attribute__((noinline))
     15 static void sys_spawn2(void)
     16 {
     17    kspawn_attr_t ksa;
     18    ksa.ksa_version = x0 + SPAWN_VERSION;
     19    ksa.ksa_size = x0 + sizeof(ksa);
     20    ksa.ksa_attr_off = x0 + 0;
     21    ksa.ksa_path_off = x0 + 0;
     22    ksa.ksa_shell_off = x0 + 0;
     23    char *argenv = "";
     24 
     25    GO(SYS_spawn, "9s 1m");
     26    SY(SYS_spawn, x0 + 1, x0 + &ksa, sizeof(ksa), x0 + argenv, x0 + 1); FAIL;
     27 }
     28 
     29 __attribute__((noinline))
     30 static void sys_spawn3(void)
     31 {
     32    kspawn_attr_t ksa;
     33    ksa.ksa_version = x0 + SPAWN_VERSION;
     34    ksa.ksa_size = x0 + 0xbadcaffe;
     35    ksa.ksa_attr_off = x0 + 0xbadcaffe;
     36    ksa.ksa_attr_size = x0 + 1;
     37    ksa.ksa_path_off = x0 + 0xdeadcaffe;
     38    ksa.ksa_path_size = x0 + 2;
     39    ksa.ksa_shell_off = x0 + 0xdeadcaffe;
     40    ksa.ksa_shell_size = x0 + 3;
     41    char *argenv = "\1arg1\0\1arg2\0\1arg3\0\0\1env1\0\1env2\0\0";
     42 
     43    GO(SYS_spawn, "13s 4m");
     44    SY(SYS_spawn, x0 + 1, x0 + &ksa, x0 + 0xbadcaffe,
     45       x0 + argenv, x0 + sizeof(argenv)); FAIL;
     46 }
     47 
     48 __attribute__((noinline))
     49 static void sys_spawn4(void)
     50 {
     51    char path[] = "/bin/sh";
     52    char *argenv = "\2arg1\0\0";
     53 
     54    GO(SYS_spawn, "4s 0m");
     55    SY(SYS_spawn, path, x0, x0, x0 + argenv, x0 + sizeof(argenv));
     56    FAILx(EINVAL);
     57 }
     58 
     59 int main(void)
     60 {
     61    /* Uninitialised, but we know px[0] is 0x0. */
     62    long *px = malloc(sizeof(long));
     63    x0 = px[0];
     64 
     65    /* SYS_spawn                   2 */
     66    sys_spawn();
     67    sys_spawn2();
     68    sys_spawn3();
     69    sys_spawn4();
     70 
     71    return 0;
     72 }
     73