コード例 #1
0
ファイル: iothread.c プロジェクト: je-so/js-projekt
int unittest_io_iosys_iothread()
{
   int err;

   TEST(0 == execasprocess_unittest(&childprocess_unittest, &err));

   return err;
ONERR:
   return EINVAL;
}
コード例 #2
0
int unittest_platform_X11_x11display()
{
   int err;

   TEST(0 == execasprocess_unittest(&childprocess_unittest, &err));

   return err;
ONERR:
   return EINVAL;
}
コード例 #3
0
ファイル: window.c プロジェクト: je-so/js-projekt
int unittest_graphic_window()
{
   int err;

   TEST(0 == execasprocess_unittest(&childprocess_unittest, &err));

   return err;
ONERR:
   return EINVAL;
}
コード例 #4
0
ファイル: syslogin.c プロジェクト: je-so/js-projekt
int unittest_platform_syslogin()
{
   int err;

   TEST(0 == execasprocess_unittest(&childprocess_unittest, &err));

   return err;
ONERR:
   return EINVAL;
}
コード例 #5
0
ファイル: syslogin.c プロジェクト: je-so/js-projekt
static int test_switchandset(void)
{
   int err;
   syslogin_t oldlogin = *syslogin_maincontext();

   if (  realuser_syslogin(syslogin_maincontext())
         == privilegeduser_syslogin(syslogin_maincontext())) {
      logwarning_unittest("Need set-user-ID bit to test switching user");
   }

   for (int tr = 0; tr <= 3; ++tr) {
      // TEST switchtoprivilegeduser_syslogin
      TEST(getuid()  == syslogin_maincontext()->currentuser);
      TEST(getuid()  == syslogin_maincontext()->realuser);
      TEST(geteuid() == syslogin_maincontext()->realuser);
      TEST(0 == switchtoprivilegeduser_syslogin(syslogin_maincontext()));
      TEST(getuid()  == syslogin_maincontext()->realuser);
      TEST(geteuid() == syslogin_maincontext()->privilegeduser);
      TEST(syslogin_maincontext()->currentuser    == oldlogin.privilegeduser);
      TEST(syslogin_maincontext()->realuser       == oldlogin.realuser);
      TEST(syslogin_maincontext()->privilegeduser == oldlogin.privilegeduser);

      // TEST switchtorealuser_syslogin
      TEST(0 == switchtorealuser_syslogin(syslogin_maincontext()));
      TEST(getuid()  == syslogin_maincontext()->realuser);
      TEST(geteuid() == syslogin_maincontext()->realuser);
      TEST(syslogin_maincontext()->currentuser    == oldlogin.currentuser);
      TEST(syslogin_maincontext()->realuser       == oldlogin.realuser);
      TEST(syslogin_maincontext()->privilegeduser == oldlogin.privilegeduser);
   }

   // TEST switchpermanent_syslogin: realuser
   TEST(0 == execasprocess_unittest(&process_switchpermreal, &err));
   TEST(0 == err);

   // TEST switchpermanent_syslogin: privilegeduser
   TEST(0 == execasprocess_unittest(&process_switchpermpriv, &err));
   TEST(0 == err);

   return 0;
ONERR:
   return EINVAL;
}
コード例 #6
0
ファイル: logcontext.c プロジェクト: je-so/js-projekt
static int test_error(void)
{
   logcontext_error_t ec = logcontext_error_FREE;

   // === group: lifetime

   // TEST logcontext_error_FREE
   TEST(0 == ec.offsets);
   TEST(0 == ec.strings);

   // prepare
   logcontext_t lc = logcontext_FREE;
   TEST(0 == init_logcontext(&lc));

   // === group: query

   // TEST s_logcontext_err_strings: last byte is '\0' byte
   TEST(0 == s_logcontext_err_strings[lengthof(s_logcontext_err_strings)-1]);
   TEST(0 != s_logcontext_err_strings[lengthof(s_logcontext_err_strings)-2]);

   // TEST maxsyserrno_logcontext: check returned value is correct
   TEST(0 < maxsyserrno_logcontext() && maxsyserrno_logcontext() < 255);
   for (unsigned i=1u+maxsyserrno_logcontext(); i<=255; ++i) {
      const uint8_t* unknown = errstr_logcontext(&lc, 255);
      const char* expect_de = "Unbekannter Fehler";
      const char* expect_en = "Unknown error";
      const uint8_t* errstr = errstr_logcontext(&lc, i);
      (void) expect_de; (void) expect_en; // no warning for unsued variable
      // check unknown error code
      TEST(0 == strcmp(CONCAT(expect_, KONFIG_LANG), (const char*)errstr));
      TEST(unknown == errstr);
   }

   // TEST errstr_logcontext: check system error codes
   for (unsigned i=0; i<=maxsyserrno_logcontext(); ++i) {
      const uint8_t* unknown = errstr_logcontext(&lc, 255);
      const char* expect_de = "Unbekannter Fehler";
      const char* expect_en = "Unknown error";
      const uint8_t* errstr = errstr_logcontext(&lc, i);
      (void) expect_de; (void) expect_en; // no warning for unsued variable
      // check not unknown error code
      TEST(0 != strcmp(CONCAT(expect_, KONFIG_LANG), (const char*)errstr));
      TEST(unknown != errstr);
   }

   // TEST errstr_logcontext: check system error descriptions match descriptions of err table
   int err;
   TEST(0 == execasprocess_unittest(&test_errtable_match_OStable, &err));
   TEST(0 == err);

   // TEST errstr_logcontext: defined application error codes
   for (unsigned i=256; i<errornr_NEXTERRORCODE; ++i) {
      const uint8_t* unknown = errstr_logcontext(&lc, 255);
      // valid content
      TEST(unknown != errstr_logcontext(&lc, i));
   }

   // TEST errstr_logcontext: undefined application error codes
   for (unsigned i=errornr_NEXTERRORCODE; i<512; ++i) {
      const uint8_t* unknown = errstr_logcontext(&lc, 255);
      TEST(unknown == errstr_logcontext(&lc, i));
   }

   // TEST errstr_logcontext: error codes > 511
   for (unsigned i=512; i; i<<=1) {
      const uint8_t* unknown = errstr_logcontext(&lc, 255);
      TEST(unknown == errstr_logcontext(&lc, i));
   }

   // reset
   TEST(0 == free_logcontext(&lc));

   return 0;
ONERR:
   free_logcontext(&lc);
   return EINVAL;
}