Exemplo n.º 1
0
int vAllocate_Deallocate_basic()
{
    TEST_START();
    unsigned int BufSize = 1024*1024;
    unsigned int BufAddr = (unsigned int)new unsigned char[BufSize];
    unsigned int BufMVA;

    ///> --------------------2. allocate MVA
    MTKM4UDrv CM4u;

    CM4u.m4u_enable_m4u_func(M4U_CLNTMOD_RDMA);
    
    // allocate MVA buffer for m4u module                    
    CM4u.m4u_alloc_mva(M4U_CLNTMOD_RDMA,     // Module ID
                       BufAddr,              // buffer virtual start address
                       BufSize,              // buffer size
                       0,
                       0,
                       &BufMVA);             // return MVA address

    M4UDBG(" after m4u_alloc_mva(), BufMVA=0x%x \r\n", BufMVA);

    CM4u.m4u_dump_info(M4U_CLNTMOD_RDMA);

    CM4u.m4u_dealloc_mva(M4U_CLNTMOD_RDMA, BufAddr, BufSize, BufMVA);
    M4UDBG(" after m4u_dealloc_mva() \r\n");
    CM4u.m4u_dump_info(M4U_CLNTMOD_RDMA);
    
    TEST_END();

    return 0;
}
Exemplo n.º 2
0
int main()
{
	TEST_SET_START("20060918101000NM","NM", "llrintf4");

//   unsigned long i11 = 0x5efffffful; // 9223371487098961920
//   unsigned long i12 = 0xdefffffful; //-9223371487098961920
//   unsigned long i11 = 0x49fffffful; //2097151.875000
//   unsigned long i12 = 0x4a7ffffful; //4194303.750000

//   float x0  = hide_float(-FLT_MAX);           // -Inf
//   float x1  = hide_float(FLT_MAX);            // Inf
   float x2  = hide_float(0.0);                  // +0
   float x3  = hide_float(-0.0);                 // -0
//   float x4  = hide_float(NANF);            // NaN -> NaN
   float x5  = hide_float( 0.5);
   float x6  = hide_float(-0.5);
   float x7  = hide_float(-0.499999);
   float x8  = hide_float( 0.499999);
   float x9  = hide_float(-999999.5);
   float x10 = hide_float( 999999.5);
//   float x11 = hide_float(make_float(i11));
//   float x12 = hide_float(make_float(i12));
   float x11 = hide_float( 9223371487098961920.);
   float x12 = hide_float(-9223371487098961920.);
   float x13 = (0.0 - FLT_MIN);
   float x14 = FLT_MIN;
   float x15 = hide_float(-2097151.875000);
   float x16 = hide_float(-4194303.750000);
   float x17 = hide_float( 4194303.750000);
   float x18 = hide_float( 2097151.875000);

	vec_float4  x0_v = ((vec_float4){ x2, x3, x5, x6});
	llroundf4_t r0_v = set_llrintf4_t(0,  0,  0, 0);

	vec_float4  x1_v = ((vec_float4){ x7, x8,       x9,     x10});
	llroundf4_t r1_v = set_llrintf4_t(0,  0, -999999, 999999);

	vec_float4  x2_v = ((vec_float4){                    x11,                    x12, x13, x14});
	llroundf4_t r2_v = set_llrintf4_t(9223371487098961920ll, -9223371487098961920ll,    0,  0);

	vec_float4  x3_v = ((vec_float4){       x15,      x16,     x17,     x18});
	llroundf4_t r3_v = set_llrintf4_t(-2097151, -4194303, 4194303, 2097151);

	llroundf4_t  res_v;

   TEST_START("llrintf4");
   res_v = llrintf4 (x0_v);
   TEST_CHECK("20060918101001NM", allequal_llroundf4( res_v, r0_v ), 0);
   res_v = llrintf4 (x1_v);
   TEST_CHECK("20060918101002NM", allequal_llroundf4( res_v, r1_v ), 0);
   res_v = llrintf4 (x2_v);
   TEST_CHECK("20060918101003NM", allequal_llroundf4( res_v, r2_v ), 0);
   res_v = llrintf4 (x3_v);
   TEST_CHECK("20060918101004NM", allequal_llroundf4( res_v, r3_v ), 0);

   TEST_SET_DONE();

   TEST_EXIT();

}
Exemplo n.º 3
0
void
test_s2k(void)
{
    TEST_START("s2k");

    static unsigned char salt[S2K_SALT_BYTES] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
    const char * pphrase = "ImGumbyAndYouAreNot";

    static unsigned char expected_key1[AES128_KEY_BYTES] = {
        0x0e, 0xa5, 0x00, 0x1c, 0xce, 0xad, 0x7e, 0xa8, 0xa0, 0x81, 0x38, 0xae, 0xaf, 0x4e, 0x28, 0xd5
    };
    unsigned char s2k_key1[AES128_KEY_BYTES];

    compute_gpg_s2k_key(pphrase, sizeof(s2k_key1), salt, S2K_ITER_BYTE_COUNT, s2k_key1);
    ASSERT_INT_EQ(memcmp(s2k_key1, expected_key1, sizeof(s2k_key1)), 0);

    //  Second test to handle the case where we need to run multiple hashes to generate enough bits
    //  Note that the first 16 bytes are the same as the previous test - this is to be expected, since the
    //  salt and passphrase are the same, so the first hash is executed identically.
    static unsigned char expected_key2[48] = {
        0x0e, 0xa5, 0x00, 0x1c, 0xce, 0xad, 0x7e, 0xa8, 0xa0, 0x81, 0x38, 0xae, 0xaf, 0x4e, 0x28, 0xd5,
        0x21, 0xf1, 0xee, 0x4b, 0x02, 0xc0, 0x0f, 0x63, 0x6a, 0x17, 0xbf, 0x62, 0x34, 0x10, 0x26, 0x48,
        0x7b, 0xc6, 0x3f, 0x08, 0x9d, 0xb5, 0x6b, 0x34, 0x70, 0x3b, 0x71, 0xdb, 0x67, 0x92, 0x6f, 0x5f
    };
    unsigned char s2k_key2[48];

    compute_gpg_s2k_key(pphrase, sizeof(s2k_key2), salt, S2K_ITER_BYTE_COUNT, s2k_key2);
    ASSERT_INT_EQ(memcmp(s2k_key2, expected_key2, sizeof(s2k_key2)), 0);

    TEST_DONE();
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_cat());
	TEST_END();
	return 0;
}
Exemplo n.º 5
0
void
tests(void)
{
	char	*loc;

	TEST_START("utf8_setlocale");
	loc = setlocale(LC_CTYPE, "en_US.UTF-8");
	ASSERT_PTR_NE(loc, NULL);
	TEST_DONE();

	badarg();
	one("null", NULL, 8, 6, 6, "(null)");
	one("empty", "", 2, 0, 0, "");
	one("ascii", "x", -2, -2, -2, "x");
	one("newline", "a\nb", -2, -2, -2, "a\nb");
	one("cr", "a\rb", -2, -2, -2, "a\rb");
	one("tab", "a\tb", -2, -2, -2, "a\tb");
	one("esc", "\033x", -2, -2, -2, "\\033x");
	one("inv_badbyte", "\377x", -2, -2, -2, "\\377x");
	one("inv_nocont", "\341x", -2, -2, -2, "\\341x");
	one("inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
	one("sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
	one("sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
	one("width_ascii", "123", 2, 2, -1, "12");
	one("width_double", "a\343\201\201", 2, 1, -1, "a");
	one("double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
	one("double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
	TEST_START();

	display = get_display();

	/* get an appropriate EGL frame buffer configuration */
	ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config));
	DEBUG_MSG("num_config: %d", num_config);

	/* create an EGL rendering context */
	ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list));

	TEST(test_tex(0, 0, 0));
	TEST(test_tex(0, 1, 0));
	TEST(test_tex(1, 0, 0));
	TEST(test_tex(1, 1, 0));
	TEST(test_tex(1, 2, 0));
	TEST(test_tex(2, 1, 0));
	TEST(test_tex(2, 2, 0));
	TEST(test_tex(0, 3, 0));
	TEST(test_tex(3, 2, 0));

	TEST(test_tex(3, 0, 1));
	TEST(test_tex(0, 3, 1));
	TEST(test_tex(3, 3, 1));
	TEST(test_tex(1, 2, 1));
	TEST(test_tex(2, 1, 1));

	ECHK(eglTerminate(display));
	TEST_END();

	return 0;
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_quad_textured(0, 0));
	TEST(test_quad_textured(0, 1));
	TEST(test_quad_textured(0, 2));
	TEST(test_quad_textured(0, 3));
	TEST(test_quad_textured(0, 4));
	TEST(test_quad_textured(0, 5));
	TEST(test_quad_textured(0, 6));
	TEST(test_quad_textured(0, 7));
	TEST(test_quad_textured(0, 8));
	TEST(test_quad_textured(0, 9));
	TEST(test_quad_textured(1, GL_NEVER));
	TEST(test_quad_textured(1, GL_LESS));
	TEST(test_quad_textured(1, GL_EQUAL));
	TEST(test_quad_textured(1, GL_LEQUAL));
	TEST(test_quad_textured(1, GL_GREATER));
	TEST(test_quad_textured(1, GL_NOTEQUAL));
	TEST(test_quad_textured(1, GL_GEQUAL));
	TEST(test_quad_textured(1, GL_ALWAYS));
	TEST_END();

	return 0;
}
Exemplo n.º 8
0
static int test_db_single_get(T *db)
{
    int r, ks, vs;
    char *kdata, *vdp, *kdp;
    
    kdata = MY_Malloc(l_ksize + 32);

    TEST_START();
    sprintf(kdata, "%s", l_prefix);
    ks = strlen(kdata);

    if (dbver == 1) {
#if 0
        r = db_get(db, kdata, ks, &vdp, &vs, NULL);
#endif
    } else {
        r = HIDB2(db_get)(db, kdata, ks, &vdp, &vs, NULL);
    }

    if (r == 0) {
        MY_Free(vdp);
        WARN("vs=%d, v=%.*s", vs, vdp);
    } else {
        WARN("%s not found or error, r=%d", kdata, r);
    }

    TEST_FIN()

    MY_Free(kdata);
    return 0;
}
Exemplo n.º 9
0
static int test_db_iter(T *db)
{
    int r, ks, vs, cnt = 0;
    char *k, *v, *kt, *vt;
    iter_t *it;

    TEST_START();

    if (dbver == 1) {
#if 0
        it = db_create_it(db, 15);
#endif
    } else {
        it = HIDB2(db_create_it)(db, 15);
    }

    while (1) {
        if (dbver == 1) {
#if 0
            r = db_iter(it, &k, &ks, &v, &vs, NULL);
#endif
        } else {
            r = HIDB2(db_iter)(it, &k, &ks, &v, &vs, NULL);
        }

        if (r != 0) break;

        kt = strchr(k, '-');
        vt = strchr(v, '-');
        if ((ks - (kt - k) != vs - (vt - v))) {
            ERROR("ks=%d  vs=%d  %.*s  %.*s", ks, vs, ks, k, vs, v);
            goto _next;
        }

        if (memcmp(kt, vt, ks - (kt - k)) != 0) {
            ERROR("ks=%d  vs=%d  %.*s  %.*s", ks, vs, ks, k, vs, v);
            goto _next;
        }

        WARN("ks=%d  vs=%d  %.*s  %.*s", ks, vs, ks, k, vs, v);
_next:
        cnt++;
        MY_Free(k);
        MY_Free(v);
    }

    if (dbver == 1) {
#if 0
        db_destroy_it(it);
#endif
    } else {
        HIDB2(db_destroy_it)(it);
    }

    PRINT(stdout, "iterate cnt=%d", cnt);
    TEST_FIN()

    return 0;
}
Exemplo n.º 10
0
int main(int argc, char **argv)
{
	TEST_START();
	TEST(test_multi());
	TEST_END();

	return 0;
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_strip_smoothed(0));
	TEST(test_strip_smoothed(1));
	TEST_END();

	return 0;
}
Exemplo n.º 12
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_triangle_smoothed(GL_CCW));
	TEST(test_triangle_smoothed(GL_CW));
	TEST_END();

	return 0;
}
Exemplo n.º 13
0
int main()
{
   TEST_SET_START("20040928182549EJL","EJL", "sqrtf4");

   unsigned int i3 =   0x742c4455;
   unsigned int i3r =  0x59d20034;
   unsigned int i4 =   0x75e7753f; 
   unsigned int i4r =  0x5aac1fb5;
   unsigned int i5 =   0x4baa9e3c; 
   unsigned int i5r =  0x4593c7d8;
   unsigned int i6 =   0x39344296; 
   unsigned int i6r =  0x3c56d14c; 
   unsigned int i7 =   0x68a586b0; 
   unsigned int i7r =  0x54118f09;

   float x3 = hide_float(make_float(i3));
   float x3r = hide_float(make_float(i3r));   
   float x4 = hide_float(make_float(i4));     
   float x4r = hide_float(make_float(i4r));   
   float x5 = hide_float(make_float(i5));     
   float x5r = hide_float(make_float(i5r));   
   float x6 = hide_float(make_float(i6));     
   float x6r = hide_float(make_float(i6r));   
   float x7 = hide_float(make_float(i7));
   float x7r = hide_float(make_float(i7r));
   
   vec_float4 x3_v = spu_splats(x3);
   vec_float4 x3r_v = spu_splats(x3r);
   vec_float4 x4_v = spu_splats(x4);
   vec_float4 x4r_v = spu_splats(x4r);
   vec_float4 x5_v = spu_splats(x5);
   vec_float4 x5r_v = spu_splats(x5r);
   vec_float4 x6_v = spu_splats(x6);
   vec_float4 x6r_v = spu_splats(x6r);
   vec_float4 x7_v = spu_splats(x7);
   vec_float4 x7r_v = spu_splats(x7r);
   
   vec_float4 res_v;

   TEST_START("sqrtf4");
   res_v = sqrtf4(x3_v);
   TEST_CHECK("20040928182552EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
   res_v = sqrtf4(x4_v);
   TEST_CHECK("20040928182554EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
   res_v = sqrtf4(x5_v);
   TEST_CHECK("20040928182556EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
   res_v = sqrtf4(x6_v);
   TEST_CHECK("20040928182557EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
   res_v = sqrtf4(x7_v);
   TEST_CHECK("20040928182559EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
   
   TEST_SET_DONE();
   
   TEST_EXIT();
}
Exemplo n.º 14
0
int main()
{
   TEST_SET_START("20040916145017EJL","EJL", "floorf");
   
   unsigned int i3 = 0x4affffff;  // 2^23 - 0.5, largest truncatable value.           
   unsigned int i3i = 0x4afffffe;                                                      
   unsigned int i4 = 0x4b000000;  // 2^23, no fractional part.                        
   unsigned int i5 = 0xcf000001;  // -2^31, one more large, and negative, value.      

   float x0 = hide_float(0.91825f);
   float x0i = hide_float(0.0f);
   float x1 = hide_float(-0.12958f);
   float x1i = hide_float(-1.0f);
   float x2 = hide_float(-79615.1875f);
   float x2i = hide_float(-79616.0f);
   float x3 = hide_float(make_float(i3));
   float x3i = hide_float(make_float(i3i));
   float x4 = hide_float(make_float(i4));
   float x4i = hide_float(make_float(i4));
   float x5 = hide_float(make_float(i5));
   float x5i = hide_float(make_float(i5));

   vec_float4 x0_v = vec_splat_float(x0);
   vec_float4 x0i_v = vec_splat_float(x0i);
   vec_float4 x1_v = vec_splat_float(x1);
   vec_float4 x1i_v = vec_splat_float(x1i);
   vec_float4 x2_v = vec_splat_float(x2);
   vec_float4 x2i_v = vec_splat_float(x2i);
   vec_float4 x3_v = vec_splat_float(x3);
   vec_float4 x3i_v = vec_splat_float(x3i);
   vec_float4 x4_v = vec_splat_float(x4);
   vec_float4 x4i_v = vec_splat_float(x4i);
   vec_float4 x5_v = vec_splat_float(x5);
   vec_float4 x5i_v = vec_splat_float(x5i);
   
   vec_float4 res_v;

   TEST_START("floorf4");
   res_v = floorf4(x0_v);
   TEST_CHECK("20040916145022EJL", allequal_float4( res_v, x0i_v ), 0);
   res_v = floorf4(x1_v);
   TEST_CHECK("20040916145024EJL", allequal_float4( res_v, x1i_v ), 0);
   res_v = floorf4(x2_v);
   TEST_CHECK("20040916145027EJL", allequal_float4( res_v, x2i_v ), 0);
   res_v = floorf4(x3_v);
   TEST_CHECK("20040916145029EJL", allequal_float4( res_v, x3i_v ), 0);
   res_v = floorf4(x4_v);
   TEST_CHECK("20040916145032EJL", allequal_float4( res_v, x4i_v ), 0);
   res_v = floorf4(x5_v);
   TEST_CHECK("20040916145034EJL", allequal_float4( res_v, x5i_v ), 0);
   
   TEST_SET_DONE();
   
   TEST_EXIT();
}
Exemplo n.º 15
0
int main()
{
   TEST_SET_START("20040928182349EJL","EJL", "rsqrtf4");

   unsigned int i3 =   0x742c4455;
   unsigned int i3r =  0x251c099a;
   unsigned int i4 =   0x75e7753f; 
   unsigned int i4r =  0x243e5fe2;
   unsigned int i5 =   0x4baa9e3c; 
   unsigned int i5r =  0x395dbbeb;
   unsigned int i6 =   0x39344296; 
   unsigned int i6r =  0x429889eb; 
   unsigned int i7 =   0x68a586b0; 
   unsigned int i7r =  0x2ae11e67;

   float x3 = hide_float(make_float(i3));
   float x3r = hide_float(make_float(i3r));   
   float x4 = hide_float(make_float(i4));     
   float x4r = hide_float(make_float(i4r));   
   float x5 = hide_float(make_float(i5));     
   float x5r = hide_float(make_float(i5r));   
   float x6 = hide_float(make_float(i6));     
   float x6r = hide_float(make_float(i6r));   
   float x7 = hide_float(make_float(i7));
   float x7r = hide_float(make_float(i7r));
   
   vec_float4 x3_v = spu_splats(x3);
   vec_float4 x3r_v = spu_splats(x3r);
   vec_float4 x4_v = spu_splats(x4);
   vec_float4 x4r_v = spu_splats(x4r);
   vec_float4 x5_v = spu_splats(x5);
   vec_float4 x5r_v = spu_splats(x5r);
   vec_float4 x6_v = spu_splats(x6);
   vec_float4 x6r_v = spu_splats(x6r);
   vec_float4 x7_v = spu_splats(x7);
   vec_float4 x7r_v = spu_splats(x7r);
   
   vec_float4 res_v;

   TEST_START("rsqrtf4");
   res_v = rsqrtf4(x3_v);
   TEST_CHECK("20040928182352EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
   res_v = rsqrtf4(x4_v);
   TEST_CHECK("20040928182355EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
   res_v = rsqrtf4(x5_v);
   TEST_CHECK("20040928182357EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
   res_v = rsqrtf4(x6_v);
   TEST_CHECK("20040928182358EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
   res_v = rsqrtf4(x7_v);
   TEST_CHECK("20040928182401EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
   
   TEST_SET_DONE();
   
   TEST_EXIT();
}
Exemplo n.º 16
0
void *root_thread(void *cookie)
{
    TEST_START(0);

    TEST_CHECK_SEQUENCE(SEQ("root", 1),
                        END_SEQ);

    TEST_FINISH();

    return NULL;
}
Exemplo n.º 17
0
static int test_db_pdel(T *db)
{
    int r = 0;

    TEST_START()
    r = HIDB2(db_pdel)(db, l_prefix, strlen(l_prefix));
    if (r != 0) return r;

    TEST_FIN()

    return 0;
}
Exemplo n.º 18
0
int test_multiple_writes(void)
{
    const char *output = "Zorba!\n";
    int maxcount = 5;
    int fd = open(g_testfilepath, O_CREAT|O_RDWR, 0644);
    int i = 0;
    int total = 0;
    int result = 0;
    int old_errno = errno;

    TEST_START();

    if (fd < 0) {
        TEST_FAIL();
        TEST_COMPLETE_FAIL("Unable to create file %s\n"
                           "Errno %d: %s\n",
                           g_testfilepath, old_errno, strerror(old_errno));
    }
    TEST_OK();

    for (i=0; i<maxcount; i++) {
        total = 0;
        result = 0;

        while (total < strlen(output)) {
            result = write(fd, output + total, strlen(output));
            old_errno = errno;

            if (result < 0) {
                close(fd);

                TEST_FAIL();
                TEST_COMPLETE_FAIL("Unable to write to file %s\n"
                                   "Errno %d: %s\n",
                                   g_testfilepath, old_errno,
                                   strerror(old_errno));
            }

            total += result;
        }
    }
    TEST_OK();

    if (close(fd) < 0) {
        TEST_FAIL();
        TEST_COMPLETE_FAIL("Unable to close %s\nErrno %d: %s\n",
                           g_testfilepath, errno, strerror(errno));
    }
    TEST_OK();

    TEST_COMPLETE_OK();
}
void TestHandle(void) {
  marisa_trie *trie = NULL;

  TEST_START();

  ASSERT(marisa_init(&trie) == MARISA_OK);
  ASSERT(marisa_init(&trie) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_end(trie) == MARISA_OK);
  ASSERT(marisa_end(NULL) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_build(NULL, NULL, 0, NULL, NULL, NULL, 0) ==
      MARISA_HANDLE_ERROR);

  ASSERT(marisa_mmap(NULL, NULL, 0, 0) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_map(NULL, NULL, 0) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_load(NULL, NULL, 0, 0) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_fread(NULL, NULL) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_read(NULL, 0) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_save(NULL, NULL, 0, 0, 0) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_fwrite(NULL, NULL) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_write(NULL, 0) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_restore(NULL, 0, NULL, 0, NULL) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_lookup(NULL, NULL, 0, NULL) == MARISA_HANDLE_ERROR);

  ASSERT(marisa_find(NULL, NULL, 0, NULL, NULL, 0, NULL) ==
      MARISA_HANDLE_ERROR);
  ASSERT(marisa_find_first(NULL, NULL, 0, NULL, NULL) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_find_last(NULL, NULL, 0, NULL, NULL) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_find_callback(NULL, NULL, 0, NULL, NULL) ==
      MARISA_HANDLE_ERROR);

  ASSERT(marisa_predict(NULL, NULL, 0, NULL, 0, NULL) == MARISA_HANDLE_ERROR);
  ASSERT(marisa_predict_breadth_first(NULL, NULL, 0, NULL, 0, NULL) ==
      MARISA_HANDLE_ERROR);
  ASSERT(marisa_predict_depth_first(NULL, NULL, 0, NULL, 0, NULL) ==
      MARISA_HANDLE_ERROR);
  ASSERT(marisa_predict_callback(NULL, NULL, 0, NULL, NULL) ==
      MARISA_HANDLE_ERROR);

  ASSERT(marisa_get_num_tries(NULL) == 0);
  ASSERT(marisa_get_num_keys(NULL) == 0);
  ASSERT(marisa_get_num_nodes(NULL) == 0);
  ASSERT(marisa_get_total_size(NULL) == 0);

  ASSERT(marisa_clear(NULL) == MARISA_HANDLE_ERROR);

  TEST_END();
}
Exemplo n.º 20
0
int
main()
{
  TEST_START("Node traversal tests");

  test_pop_node_returns_the_last_node_in_a_linked_list();
  test_rewind_node_resets_a_previous_sequence_of_pops();
  test_empty_returns_true_on_an_emptied_list();
  
  TEST_SUMMARY();

  return 0;
}
Exemplo n.º 21
0
int test_single_write(void)
{
    const char *output = "Zorba!\n";
    int fd = open(g_testfilepath, O_CREAT|O_RDWR, 0644);
    int total = 0;
    int result = 0;
    int old_errno = errno;

    TEST_START();

    if (fd < 0) {
        TEST_FAIL();
        TEST_COMPLETE_FAIL("Unable to open %s in %s\n"
                           "Errno %d: %s\n",
                           g_testfilepath, __func__,
                           old_errno, strerror(old_errno));
    }
    TEST_OK();

    while (total < strlen(output)) {
        result = write(fd, output + total, strlen(output));

        if (result < 0) {
            old_errno = errno;
            TEST_FAIL();
            TEST_COMPLETE_FAIL("Unable to write to %s in %s\n"
                               "Errno %d: %s\n",
                               g_testfilepath, __func__,
                               old_errno, strerror(old_errno));

            // Don't care about this output -- we're going to die soon, anyway.
            close(fd);
        }

        total += result;
    }
    TEST_OK();

    if (close(fd) < 0) {
        old_errno = errno;

        TEST_FAIL();
        TEST_COMPLETE_FAIL("Unable to close %s in %s\n"
                           "Errno %d: %s\n",
                           g_testfilepath, __func__,
                           old_errno, strerror(old_errno));
    }
    TEST_OK();

    TEST_COMPLETE_OK();
}
Exemplo n.º 22
0
void
badarg(void)
{
	char	 buf[16];
	int	 len, width;

	width = 1;
	TEST_START("utf8_badarg");
	len = snmprintf(buf, sizeof(buf), &width, "\377");
	ASSERT_INT_EQ(len, -1);
	ASSERT_STRING_EQ(buf, "");
	ASSERT_INT_EQ(width, 0);
	TEST_DONE();
}
void
sshbuf_getput_fuzz_tests(void)
{
	u_char blob[] = {
		/* u8 */
		0xd0,
		/* u16 */
		0xc0, 0xde,
		/* u32 */
		0xfa, 0xce, 0xde, 0xad,
		/* u64 */
		0xfe, 0xed, 0xac, 0x1d, 0x1f, 0x1c, 0xbe, 0xef,
		/* string */
		0x00, 0x00, 0x00, 0x09,
		'O', ' ', 'G', 'o', 'r', 'g', 'o', 'n', '!',
		/* bignum1 */
		0x79,
		0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
		0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
		/* bignum2 */
		0x00, 0x00, 0x00, 0x14,
		0x00,
		0xf0, 0xe0, 0xd0, 0xc0, 0xb0, 0xa0, 0x90, 0x80,
		0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0x00,
		0x7f, 0xff, 0x11,
		/* EC point (NIST-256 curve) */
		0x00, 0x00, 0x00, 0x41,
		0x04,
		0x0c, 0x82, 0x80, 0x04, 0x83, 0x9d, 0x01, 0x06,
		0xaa, 0x59, 0x57, 0x52, 0x16, 0x19, 0x13, 0x57,
		0x34, 0xb4, 0x51, 0x45, 0x9d, 0xad, 0xb5, 0x86,
		0x67, 0x7e, 0xf9, 0xdf, 0x55, 0x78, 0x49, 0x99,
		0x4d, 0x19, 0x6b, 0x50, 0xf0, 0xb4, 0xe9, 0x4b,
		0x3c, 0x73, 0xe3, 0xa9, 0xd4, 0xcd, 0x9d, 0xf2,
		0xc8, 0xf9, 0xa3, 0x5e, 0x42, 0xbd, 0xd0, 0x47,
		0x55, 0x0f, 0x69, 0xd8, 0x0e, 0xc2, 0x3c, 0xd4,
	};
	struct fuzz *fuzz;

	TEST_START("fuzz blob parsing");
	fuzz = fuzz_begin(FUZZ_1_BIT_FLIP | FUZZ_2_BIT_FLIP |
	    FUZZ_1_BYTE_FLIP | FUZZ_2_BYTE_FLIP |
	    FUZZ_TRUNCATE_START | FUZZ_TRUNCATE_END, blob, sizeof(blob));
	TEST_ONERROR(onerror, fuzz);
	for(; !fuzz_done(fuzz); fuzz_next(fuzz))
		attempt_parse_blob(blob, sizeof(blob));
	fuzz_cleanup(fuzz);
	TEST_DONE();
	TEST_ONERROR(NULL, NULL);
}
Exemplo n.º 24
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_quad_instanced(  0,   1,  1));
	TEST(test_quad_instanced(  1,   1,  1));
	TEST(test_quad_instanced(  7,   1,  1));
	TEST(test_quad_instanced( 31,   7, 11));
	TEST(test_quad_instanced( 66,   1,  1));
	TEST(test_quad_instanced(300,   1,  1));
	TEST(test_quad_instanced(300,   7, 37));
	TEST_END();

	return 0;
}
Exemplo n.º 25
0
int main()
{
    TEST_SET_START("20040930102649EJL","EJL", "negatef4");

    unsigned int i3n = 0xffffffff;
    unsigned int i3p = 0x7fffffff;

    float x0n = hide_float(-0.0f);
    float x0p = hide_float(0.0f);
    float x1n = hide_float(-83532.96153153f);
    float x1p = hide_float(83532.96153153f);
    float x2n = hide_float(-0.0000000013152f);
    float x2p = hide_float(0.0000000013152f);
    float x3n = hide_float(make_float(i3n));
    float x3p = hide_float(make_float(i3p));

    vec_float4 x0n_v = spu_splats(x0n);
    vec_float4 x0p_v = spu_splats(x0p);
    vec_float4 x1n_v = spu_splats(x1n);
    vec_float4 x1p_v = spu_splats(x1p);
    vec_float4 x2n_v = spu_splats(x2n);
    vec_float4 x2p_v = spu_splats(x2p);
    vec_float4 x3n_v = spu_splats(x3n);
    vec_float4 x3p_v = spu_splats(x3p);

    vec_float4 res_v;

    TEST_START("negatef4");
    res_v = negatef4(x0n_v);
    TEST_CHECK("20040930102652EJL", allequal_float4( res_v, x0p_v ), 0);
    res_v = negatef4(x0p_v);
    TEST_CHECK("20040930102653EJL", allequal_float4( res_v, x0n_v ), 0);
    res_v = negatef4(x1n_v);
    TEST_CHECK("20040930102655EJL", allequal_float4( res_v, x1p_v ), 0);
    res_v = negatef4(x1p_v);
    TEST_CHECK("20040930102657EJL", allequal_float4( res_v, x1n_v ), 0);
    res_v = negatef4(x2n_v);
    TEST_CHECK("20040930102659EJL", allequal_float4( res_v, x2p_v ), 0);
    res_v = negatef4(x2p_v);
    TEST_CHECK("20040930102701EJL", allequal_float4( res_v, x2n_v ), 0);
    res_v = negatef4(x3n_v);
    TEST_CHECK("20040930102703EJL", allequal_float4( res_v, x3p_v ), 0);
    res_v = negatef4(x3p_v);
    TEST_CHECK("20040930102705EJL", allequal_float4( res_v, x3n_v ), 0);

    TEST_SET_DONE();

    TEST_EXIT();
}
Exemplo n.º 26
0
int main()
{
   TEST_SET_START("20060731203500MH","MH", "negatell2");
   
   vec_llong2 x0n_v = spu_splats(0LL);
   vec_llong2 x0p_v = spu_splats(0LL);
   vec_llong2 x1n_v = spu_splats(-83582LL);
   vec_llong2 x1p_v = spu_splats(83582LL);
   vec_llong2 x2n_v = spu_splats(-13152LL);
   vec_llong2 x2p_v = spu_splats(13152LL);
   vec_llong2 x3n_v = spu_splats(-1LL);
   vec_llong2 x3p_v = spu_splats(1LL);
   vec_llong2 x4n_v = spu_splats((long long)0x8000000000000001ULL);
   vec_llong2 x4p_v = spu_splats(0x7fffffffffffffffLL);
   vec_llong2 x5n_v = spu_splats((long long)0x8000000100000000ULL);
   vec_llong2 x5p_v = spu_splats(0x7fffffff00000000LL);
   
   vec_llong2 res_v;

   TEST_START("negatell2");
   res_v = negatell2(x0n_v);
   TEST_CHECK("20060731203501MH", allequal_llong2( res_v, x0p_v ), 0);
   res_v = negatell2(x0p_v);
   TEST_CHECK("20060731203502MH", allequal_llong2( res_v, x0n_v ), 0);
   res_v = negatell2(x1n_v);
   TEST_CHECK("20060731203503MH", allequal_llong2( res_v, x1p_v ), 0);
   res_v = negatell2(x1p_v);
   TEST_CHECK("20060731203504MH", allequal_llong2( res_v, x1n_v ), 0);
   res_v = negatell2(x2n_v);
   TEST_CHECK("20060731203505MH", allequal_llong2( res_v, x2p_v ), 0);
   res_v = negatell2(x2p_v);
   TEST_CHECK("20060731203506MH", allequal_llong2( res_v, x2n_v ), 0);
   res_v = negatell2(x3n_v);
   TEST_CHECK("20060731203507MH", allequal_llong2( res_v, x3p_v ), 0);
   res_v = negatell2(x3p_v);
   TEST_CHECK("20060731203508MH", allequal_llong2( res_v, x3n_v ), 0);
   res_v = negatell2(x4n_v);
   TEST_CHECK("20060731203509MH", allequal_llong2( res_v, x4p_v ), 0);
   res_v = negatell2(x4p_v);
   TEST_CHECK("20060731203510MH", allequal_llong2( res_v, x4n_v ), 0);
   res_v = negatell2(x5n_v);
   TEST_CHECK("20060731203511MH", allequal_llong2( res_v, x5p_v ), 0);
   res_v = negatell2(x5p_v);
   TEST_CHECK("20060731203512MH", allequal_llong2( res_v, x5n_v ), 0);
   
   TEST_SET_DONE();
   
   TEST_EXIT();
}
Exemplo n.º 27
0
int
main()
{
  TEST_START("Helper tests");

  test_get_arg_can_retrieve_first_arg();
  test_get_arg_handles_empty_case();
  test_get_arg_can_retrieve_the_nth_arg();
  test_arg_len_returns_the_number_of_arguments();
  test_arg_len_handles_empty_case();

  TEST_SUMMARY();

  return 0;
}
Exemplo n.º 28
0
int main(int argc, char *argv[])
{
	TEST_START();
	TEST(test_query(0,  400,  240));
	TEST(test_query(1,  400,  240));
	TEST(test_query(2,  400,  240));
	TEST(test_query(0,  800,  600));
	TEST(test_query(1,  800,  600));
	TEST(test_query(2,  800,  600));
	TEST(test_query(0, 1920, 1080));
	TEST(test_query(1, 1920, 1080));
	TEST(test_query(2, 1920, 1080));
	TEST_END();

	return 0;
}
Exemplo n.º 29
0
int main(int argc, char *argv[])
{
	static const int samples[] = { 0, 2, 4, };
	int i;
	TEST_START();

	for (i = 0;  i < ARRAY_SIZE(samples); i++) {
		/* seems like, similar to a2xx, we only have z16 and z24s8: */
		TEST(test_triangle_quad(samples[i], EGL_DONT_CARE, EGL_DONT_CARE));
		TEST(test_triangle_quad(samples[i], 16, EGL_DONT_CARE));
		TEST(test_triangle_quad(samples[i], 24, 8));
	}
	TEST_END();

	return 0;
}
Exemplo n.º 30
0
static int test_db_single_pget(T *db)
{
    int i, r, ks, vs;
    char *kdata, *vdata, *vdp, *kdp;
    iter_t *it;
    
    kdata = MY_Malloc(l_ksize + 32);
    vdata = MY_Malloc(l_vsize + 32);

    TEST_START();
    for (i = 0; i < l_kvcnt; i++) {
        sprintf(kdata, "%s-%d", kpattern, i);
        ks = strlen(kdata);

        if (dbver == 1) {
#if 0
            r = db_get(db, kdata, ks, &vdp, &vs, NULL);
#endif
        } else {
            it = HIDB2(db_pget)(db, kdata, ks);
            r = HIDB2(db_iter)(it, &kdp, &ks, &vdp, &vs, NULL);
        }

        if (r == 0) {
            sprintf(vdata, "%s-%d", vpattern, i);
            r = memcmp(vdata, vdp, vs);
            if (r != 0) {
                ERROR("i=%d, vlen=%d, vdata=%.*s", i, vs, vs, vdp);
            }

            MY_Free(kdp);
            MY_Free(vdp);
        } else {
            WARN("%s not found or error, r=%d", kdata, r);
        }

        if (dbver != 1) {
            HIDB2(db_destroy_it)(it);
        }
    }

    TEST_FIN()

    MY_Free(kdata);
    MY_Free(vdata);
    return 0;
}