Exemple #1
0
static int childprocess_unittest(void)
{
   resourceusage_t   usage = resourceusage_FREE;
   display_t         disp  = display_FREE;
   window_t          win   = window_FREE;
   window_evh_t      evhandler = window_evh_INIT_NULL;
   EGLContext        eglcontext = EGL_NO_CONTEXT;

   // prepare
   TEST(0 == initdefault_display(&disp))
   TEST(0 == init_test_window(&win, &eglcontext, &disp, &evhandler));

   if (test_transparentalpha(&disp))   goto ONERR;

   TEST(0 == init_resourceusage(&usage));

   if (test_initfree(&disp))           goto ONERR;

   acceptleak_helper(&usage);
   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   WAITFOR(&disp, false);
   size_t    logsize;
   uint8_t * logbuffer;
   GETBUFFER_ERRLOG(&logbuffer, &logsize);
   for (unsigned i = 0; i <= 2; ++i) {
      TEST(0 == init_resourceusage(&usage));

      if (test_showhide(&win, &disp))     goto ONERR;
      if (test_position(&win, &disp))     goto ONERR;
      if (test_resize(&win, &disp))       goto ONERR;

      WAITFOR(&disp, false);
      if (0 == same_resourceusage(&usage)) break;
      TEST(0 == free_resourceusage(&usage));
      TRUNCATEBUFFER_ERRLOG(logsize);
   }
   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   // unprepare
   TEST(0 == free_window(&win));
   TEST(0 == free_display(&disp));

   return 0;
ONERR:
   (void) free_resourceusage(&usage);
   (void) free_window(&win);
   (void) free_display(&disp);
   return EINVAL;
}
Exemple #2
0
static int childprocess_unittest(void)
{
    x11display_t      x11disp   = x11display_FREE ;
    x11screen_t       x11screen = x11screen_FREE ;
    resourceusage_t   usage     = resourceusage_FREE ;

    // prepare
    TEST(0 == init_x11display(&x11disp, ":0")) ;
    x11screen = defaultscreen_x11display(&x11disp) ;

    if (test_iterator(&x11screen))      goto ONERR;
    if (test_initfree(&x11screen))      goto ONERR;
    if (test_setvideomode(&x11screen))  goto ONERR; // has memory leak

    TEST(0 == init_resourceusage(&usage)) ;

    if (test_iterator(&x11screen))      goto ONERR;
    if (test_initfree(&x11screen))      goto ONERR;

    TEST(0 == same_resourceusage(&usage)) ;
    TEST(0 == free_resourceusage(&usage)) ;

    // unprepare
    TEST(0 == free_x11display(&x11disp)) ;

    return 0 ;
ONERR:
    (void) free_resourceusage(&usage) ;
    (void) free_x11display(&x11disp) ;
    return EINVAL ;
}
Exemple #3
0
static int childprocess_unittest(void)
{
   x11display_t      x11disp1 = x11display_FREE ;
   x11display_t      x11disp2 = x11display_FREE ;
   resourceusage_t   usage    = resourceusage_FREE ;

   // XQueryExtension keeps file descriptors and memory
   // without it no resource leak !
   TEST(0 == init_resourceusage(&usage)) ;
   TEST(0 == init2_x11display(&x11disp1, ":0", false)) ;
   TEST(0 == free_x11display(&x11disp1)) ;
   TEST(0 == same_resourceusage(&usage)) ;
   TEST(0 == free_resourceusage(&usage)) ;

   TEST(0 == init_resourceusage(&usage)) ;
   if (test_initfree_env())     goto ONERR;
   TEST(0 == same_resourceusage(&usage)) ;
   TEST(0 == free_resourceusage(&usage)) ;

   if (test_initfree())    goto ONERR;

   TEST(0 == init_x11display(&x11disp1, ":0")) ;
   TEST(0 == init_x11display(&x11disp2, ":0")) ;
   char errstr[100];
   errorstring_x11display(&x11disp1, 1, errstr, sizeof(errstr));

   TEST(0 == init_resourceusage(&usage)) ;

   if (test_query())                            goto ONERR;
   if (test_screen(&x11disp1, &x11disp2))       goto ONERR;
   if (test_extensions(&x11disp1))              goto ONERR;
   if (test_id_manager(&x11disp1, &x11disp2))   goto ONERR;

   TEST(0 == same_resourceusage(&usage)) ;
   TEST(0 == free_resourceusage(&usage)) ;

   TEST(0 == free_x11display(&x11disp1)) ;
   TEST(0 == free_x11display(&x11disp2)) ;

   return 0 ;
ONERR:
   (void) free_x11display(&x11disp1);
   (void) free_x11display(&x11disp2);
   (void) free_resourceusage(&usage);
   return EINVAL ;
}
Exemple #4
0
static int childprocess_unittest(void)
{
   resourceusage_t usage = resourceusage_FREE;

   if (test_logininfo())            goto ONERR;
   CLEARBUFFER_ERRLOG();

   TEST(0 == init_resourceusage(&usage));

   if (test_systypes())             goto ONERR;
   if (test_initfree())             goto ONERR;
   if (test_query())                goto ONERR;
   if (test_switchandset())         goto ONERR;
   if (test_logininfo())            goto ONERR;

   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   return 0;
ONERR:
   return EINVAL;
}
Exemple #5
0
static int childprocess_unittest(void)
{
   resourceusage_t usage = resourceusage_FREE;
   directory_t* dir = 0;
   uint8_t      dirpath[256];

   if (test_initfree())    goto ONERR;

   TEST(0 == init_resourceusage(&usage));

   // prepare
   TEST(0 == newtemp_directory(&dir, "iothread", &(wbuffer_t) wbuffer_INIT_STATIC(sizeof(dirpath), dirpath)));

   if (test_helper())      goto ONERR;
   if (test_initfree())    goto ONERR;
   if (test_noop())        goto ONERR;
   if (test_read(dir))     goto ONERR;
   if (test_write(dir))    goto ONERR;
   if (test_rwerror())     goto ONERR;
   if (test_rwpartial(dir)) goto ONERR;

   // reset
   TEST(0 == delete_directory(&dir));
   TEST(0 == removedirectory_directory(0, (const char*)dirpath));

   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   return 0;
ONERR:
   if (dir) {
      delete_directory(&dir);
      removedirectory_directory(0, (const char*)dirpath);
   }
   free_resourceusage(&usage);
   return EINVAL;
}