示例#1
0
文件: test-suse.c 项目: emaste/netcf
static void assert_transforms(CuTest *tc, const char *base) {
    char *aug_fname = NULL, *ncf_fname = NULL;
    char *aug_xml_exp = NULL, *ncf_xml_exp = NULL;
    char *aug_xml_act = NULL, *ncf_xml_act = NULL;
    int r;

    r = asprintf(&aug_fname, "suse/schema/%s.xml", base);
    r = asprintf(&ncf_fname, "interface/%s.xml", base);

    aug_xml_exp = read_test_file(tc, aug_fname);
    ncf_xml_exp = read_test_file(tc, ncf_fname);

    r = ncf_get_aug(ncf, ncf_xml_exp, &aug_xml_act);
    CuAssertIntEquals(tc, 0, r);

    r = ncf_put_aug(ncf, aug_xml_exp, &ncf_xml_act);
    CuAssertIntEquals(tc, 0, r);

    assert_xml_equals(tc, ncf_fname, ncf_xml_exp, ncf_xml_act);
    assert_xml_equals(tc, aug_fname, aug_xml_exp, aug_xml_act);

    free(ncf_xml_exp);
    free(ncf_xml_act);
    free(aug_xml_exp);
    free(aug_xml_act);
}
void test(int ix) {
	struct world_list *wl = NULL, *tmp;
	struct test test = all_tests[ix];
	char *cmd;
	int i;

	wl = calloc(1, sizeof(*wl));
	wl->world = read_test_file(test.filenames[0]);
	for (i = 1; test.filenames[i]; i++) {
		tmp = calloc(1, sizeof(*tmp));
		tmp->world = read_test_file(test.filenames[i]);
		tmp->next = wl;
		wl = tmp;
	}

	cmd = build_test_cmd(wl);
	test_results(4 + ix, cmd, test_everything, wl, test.score); /* syntax check */

	while (wl) {
		tmp = wl->next;
		free_world(wl->world);
		free(wl);
		wl = tmp;
	}
}
示例#3
0
int main(int argc, char **argv) {
    MPI_Init(&argc, &argv);
    adios_init("transforms.xml", comm);

    double *arr = malloc(N * sizeof(double));
    memset(arr, 123, N * sizeof(double));

    write_test_file(arr);
    read_test_file(arr);

    adios_finalize(0);
    MPI_Finalize();
}
示例#4
0
//处理测试文件
void process_test_file(char *filename)
{
	//打开文件并返回文件中的测试示例个数
	int nCaseCount=read_test_file(filename);
	int nMinStep[MAXTEST];

	//求解
	for(int i=0;i<nCaseCount;i++)
	{
		knight_walk(testcase[i].srci,testcase[i].srcj,testcase[i].desti,testcase[i].destj);
		nMinStep[i]=min_step();
	}

	//输出
	output_test_file(filename,nMinStep,nCaseCount);
}
示例#5
0
文件: test-suse.c 项目: emaste/netcf
static void testDefineUndefine(CuTest *tc) {
    char *bridge_xml = NULL;
    struct netcf_if *nif = NULL;
    int r;

    bridge_xml = read_test_file(tc, "interface/bridge42.xml");
    CuAssertPtrNotNull(tc, bridge_xml);

    nif = ncf_define(ncf, bridge_xml);
    CuAssertPtrNotNull(tc, nif);
    assert_ncf_no_error(tc);

    r = ncf_if_undefine(nif);
    CuAssertIntEquals(tc, 0, r);
    assert_ncf_no_error(tc);

    ncf_close(ncf);
    r = ncf_init(&ncf, root);
    CuAssertIntEquals(tc, 0, r);

    nif = ncf_lookup_by_name(ncf, "br42");
    CuAssertPtrEquals(tc, NULL, nif);
}
int mount_main(int argc, char *argv[])
{
    int  ret;

#ifndef CONFIG_EXAMPLES_MOUNT_DEVNAME
    /* Create a RAM disk for the test */

    ret = create_ramdisk();
    if (ret < 0)
    {
        printf("mount_main: ERROR failed to create RAM disk\n");
        return 1;
    }
#endif

    /* Mount the test file system (see arch/sim/src/up_deviceimage.c */

    printf("mount_main: mounting %s filesystem at target=%s with source=%s\n",
           g_filesystemtype, g_target, g_source);

    ret = mount(g_source, g_target, g_filesystemtype, 0, NULL);
    printf("mount_main: mount() returned %d\n", ret);

    if (ret == 0)
    {
        show_statfs(g_mntdir);
        show_statfs(g_target);

#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        /* Read a test file that is already on the test file system image */

        show_directories("", 0);
        succeed_stat(g_testfile1);
        show_statfs(g_testfile1);
        read_test_file(g_testfile1);
#else
        /* Create the test directory that would have been on the canned filesystem */

        succeed_mkdir(g_testdir1);
        show_directories("", 0);
        succeed_stat(g_testdir1);
        show_statfs(g_testdir1);
#endif

        /* Write a test file into a pre-existing directory on the test file system */

        fail_stat(g_testfile2, ENOENT);
        write_test_file(g_testfile2);
        show_directories("", 0);
        succeed_stat(g_testfile2);
        show_statfs(g_testfile2);

        /* Read the file that we just wrote */

        read_test_file(g_testfile2);

        /* Try rmdir() against a file on the directory.  It should fail with ENOTDIR */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        fail_rmdir(g_testfile1, ENOTDIR);
#endif

        /* Try rmdir() against the test directory.  It should fail with ENOTEMPTY */

        fail_rmdir(g_testdir1, ENOTEMPTY);

        /* Try unlink() against the test directory.  It should fail with EISDIR */

        fail_unlink(g_testdir1, EISDIR);

        /* Try unlink() against the test file1.  It should succeed. */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        succeed_unlink(g_testfile1);
        fail_stat(g_testfile1, ENOENT);
        show_directories("", 0);
#endif

        /* Attempt to open testfile1 should fail with ENOENT */
#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME
        fail_read_open(g_testfile1, ENOENT);
#endif
        /* Try rmdir() against the test directory.  It should still fail with ENOTEMPTY */

        fail_rmdir(g_testdir1, ENOTEMPTY);

        /* Try mkdir() against the test file2.  It should fail with EEXIST. */

        fail_mkdir(g_testfile2, EEXIST);

        /* Try unlink() against the test file2.  It should succeed. */

        succeed_unlink(g_testfile2);
        show_directories("", 0);
        fail_stat(g_testfile2, ENOENT);

        /* Try mkdir() against the test dir1.  It should fail with EEXIST. */

        fail_mkdir(g_testdir1, EEXIST);

        /* Try rmdir() against the test directory.  mkdir should now succeed. */

        succeed_rmdir(g_testdir1);
        show_directories("", 0);
        fail_stat(g_testdir1, ENOENT);

        /* Try mkdir() against the test dir2.  It should succeed */

        succeed_mkdir(g_testdir2);
        show_directories("", 0);
        succeed_stat(g_testdir2);
        show_statfs(g_testdir2);

        /* Try mkdir() against the test dir2.  It should fail with EXIST */

        fail_mkdir(g_testdir2, EEXIST);

        /* Write a test file into a new directory on the test file system */

        fail_stat(g_testfile3, ENOENT);
        write_test_file(g_testfile3);
        show_directories("", 0);
        succeed_stat(g_testfile3);
        show_statfs(g_testfile3);

        /* Read the file that we just wrote */

        read_test_file(g_testfile3);

        /* Use mkdir() to create test dir3.  It should succeed */

        fail_stat(g_testdir3, ENOENT);
        succeed_mkdir(g_testdir3);
        show_directories("", 0);
        succeed_stat(g_testdir3);
        show_statfs(g_testdir3);

        /* Try rename() on the root directory. Should fail with EXDEV*/

        fail_rename(g_target, g_testdir4, EXDEV);

        /* Try rename() to an existing directory.  Should fail with EEXIST */

        fail_rename(g_testdir2, g_testdir3, EEXIST);

        /* Try rename() to a non-existing directory.  Should succeed */

        fail_stat(g_testdir4, ENOENT);
        succeed_rename(g_testdir3, g_testdir4);
        show_directories("", 0);
        fail_stat(g_testdir3, ENOENT);
        succeed_stat(g_testdir4);
        show_statfs(g_testdir4);

        /* Try rename() of file.  Should work. */

        fail_stat(g_testfile4, ENOENT);
        succeed_rename(g_testfile3, g_testfile4);
        show_directories("", 0);
        fail_stat(g_testfile3, ENOENT);
        succeed_stat(g_testfile4);
        show_statfs(g_testfile4);

        /* Make sure that we can still read the renamed file */

        read_test_file(g_testfile4);

        /* Unmount the file system */

        printf("mount_main: Try unmount(%s)\n", g_target);

        ret = umount(g_target);
        if (ret != 0)
        {
            printf("mount_main: ERROR umount() failed, errno %d\n", errno);
            g_nerrors++;
        }

        printf("mount_main: %d errors reported\n", g_nerrors);
    }

    fflush(stdout);
    return 0;
}