Пример #1
0
int main(int argc, char * const argv[])
{
        struct testlist *test;
        int opt_index, c, rc = 0, numonly = 0, numexcept = 0;
        char *only[100], *except[100];
        static struct option long_opts[] = {
                {"dumpfile", 1, 0, 'd'},
                {"only", 1, 0, 'o'},
                {"except", 1, 0, 'e'},
                {"target", 1, 0, 't'},
                {"verbose", 1, 0, 'v'},
                {0, 0, 0, 0}
        };

        while ((c = getopt_long(argc, argv, "d:e:o:t:v", long_opts, &opt_index)) != -1) {
                switch (c) {
                case 'd':
                        setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
                        break;
                case 'e':
                        if (numexcept == 0)
                                printf("Not running test(s): ");
                        printf("%s ", optarg);
                        except[numexcept++] = optarg;
                        break;
                case 'o':
                        if (numonly == 0)
                                printf("Only running test(s): ");
                        printf("%s ", optarg);
                        only[numonly++] = optarg;
                        break;
                case 't':
                        setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
                        break;
                case 'v':
                        opt_verbose++;
                        break;
                default:
                        usage(argv[0]);
                        break;
                }
        }

        if (getenv(ENV_LUSTRE_MNTTGT) == NULL &&
            getenv(ENV_LUSTRE_DUMPFILE) == NULL)
                usage(argv[0]);

        if (optind != argc)
                usage(argv[0]);

        printf("\n");

        __liblustre_setup_();

        buf_size = _npages * CFS_PAGE_SIZE;
        if (opt_verbose)
                printf("allocating %d bytes buffer\n", buf_size);
        buf_alloc = calloc(1, buf_size);
        if (buf_alloc == NULL) {
                fprintf(stderr, "error allocating %d\n", buf_size);
                exit(-ENOMEM);
        }

        for (test = testlist; test->test != NULL; test++) {
                int run = 1, i;
                int len, olen;

                if (numexcept > 0) {
                        len = strlen(test->name);
                        for (i = 0; i < numexcept; i++) {
                                olen = strlen(except[i]);

                                if (len < olen)
                                        continue;

                                if (strncmp(except[i], test->name, olen) == 0) {
                                        switch(test->name[olen]) {
                                        case '0': case '1': case '2': case '3':
                                        case '4': case '5': case '6': case '7':
                                        case '8': case '9':
                                                break;
                                        default:
                                                run = 0;
                                                break;
                                        }
                                }
                        }
                }

                if (numonly > 0) {
                        run = 0;
                        len = strlen(test->name);
                        for (i = 0; i < numonly; i++) {
                                olen = strlen(only[i]);

                                if (len < olen)
                                        continue;

                                if (strncmp(only[i], test->name, olen) == 0) {
                                        switch(test->name[olen]) {
                                        case '0': case '1': case '2': case '3':
                                        case '4': case '5': case '6': case '7':
                                        case '8': case '9':
                                                break;
                                        default:
                                                run = 1;
                                                break;
                                        }
                                }
                        }
                }
                if (run && (rc = (test->test)(test->name)) != 0)
                        break;
        }

        free(buf_alloc);

        printf("liblustre is about to shutdown\n");
        __liblustre_cleanup_();

        printf("complete successfully\n");
        return rc;
}
Пример #2
0
int main(int argc, char * const argv[])
{
        int opt_index, c;
        static struct option long_opts[] = {
                {"target", 1, 0, 0},
                {"dumpfile", 1, 0, 0},
                {0, 0, 0, 0}
        };

        if (argc < 4)
                usage(argv[0]);

        while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) {
                switch (c) {
                case 0: {
                        if (!optarg[0])
                                usage(argv[0]);

                        if (!strcmp(long_opts[opt_index].name, "target")) {
                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
                        } else
                                usage(argv[0]);
                        break;
                }
                case 's':
                        strcpy(mds_server, optarg);
                        break;
                case 'b':
                        strcpy(barrier_script, optarg);
                        break;
                case 'f':
                        strcpy(failover_script, optarg);
                        break;
                default:
                        usage(argv[0]);
                }
        }

        if (optind != argc)
                usage(argv[0]);
        if (!strlen(mds_server) || !strlen(barrier_script) ||
            !strlen(failover_script))
                usage(argv[0]);

        test_ssh();

        /* prepare remote command */
        sprintf(barrier_cmd, "ssh %s \"%s\"", mds_server, barrier_script);
        sprintf(failover_cmd, "ssh %s \"%s\"", mds_server, failover_script);

        setenv(ENV_LUSTRE_TIMEOUT, "5", 1);

        __liblustre_setup_();

        t0();
        t1();
        t2();
        t3();
        t4();

	printf("liblustre is about shutdown\n");
        __liblustre_cleanup_();

	printf("complete successfully\n");
	return 0;
}
Пример #3
0
int main(int argc, char *argv[])
{
        int opt_index, c;
        static struct option long_opts[] = {
                {"target", 1, 0, 0},
                {"dumpfile", 1, 0, 0},
                {0, 0, 0, 0}
        };
	int fd;
        long time1, time2;
        struct stat statbuf;

        if (argc < 3)
                usage(argv[0]);

        while ((c = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) {
                switch (c) {
                case 0: {
                        if (!optarg[0])
                                usage(argv[0]);

                        if (!strcmp(long_opts[opt_index].name, "target")) {
                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
                        } else
                                usage(argv[0]);
                        break;
                }
                default:
                        usage(argv[0]);
                }
        }

        if (optind != argc)
                usage(argv[0]);

        __liblustre_setup_();

	MPI_CHECK(MPI_Init(&argc, &argv), "MPI_Init()");
	MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD, &numTasks), "MPI_Comm_size");
	MPI_CHECK(MPI_Comm_rank(MPI_COMM_WORLD, &rank), "MPI_Comm_rank");

        if (numTasks < 2) {
                printf("this demo can't run on single node!\n");
                goto cleanup;
        }

        if (rank == 0) {
                unlink(test_file_name);
        }

        MPI_Barrier(MPI_COMM_WORLD);
        if (rank == 1) {
                printf("Node 1: creating file %s ...\n", test_file_name);
                fflush(stdout);

                fd = open(test_file_name, O_CREAT|O_RDWR, 0755);
                if (fd < 0) {
                        printf("Node %d: creat file err: %d", rank, fd);
                        fflush(stdout);
                        goto cleanup;
                }
                close(fd);
                printf("Node 1: done creation. perform stat on file %s ...\n", test_file_name);
                fflush(stdout);

                if (stat(test_file_name, &statbuf)) {
                        printf("Node %d: stat file err: %d", rank, fd);
                        fflush(stdout);
                        goto cleanup;
                }

                printf("Node %d: done stat on file\n", rank);
                fflush(stdout);
        } else {
                printf("Node %d: waiting node 1 create & stat file\n", rank);
                fflush(stdout);
        }

        MPI_Barrier(MPI_COMM_WORLD);
        
        if (rank == 1) {
                printf("Node 1: file has been create+stat, abort excution here!!!!!!!\n");
                fflush(stdout);
                exit(0);
        }
        
        sleep(1);
        printf("Node %d: synced with Node 1. sleep 5 seconds...\n", rank);
        fflush(stdout);
        sleep(5);
        printf("Node %d: wakeup from sleep. perform unlink()...\n", rank);
        fflush(stdout);

        time1 = time(NULL);
        if (unlink(test_file_name)) {
                printf("Node %d: error unlink file: %s\n", rank, test_file_name);
                fflush(stdout);
                goto cleanup;
        }
        time2 = time(NULL);
        printf("Node %d: successfully unlink file, cost %ld seconds.\n",
                rank, time2 - time1);
        fflush(stdout);

cleanup:
        __liblustre_cleanup_();
        printf("Node %d: end sucessfully.\n", rank);
	return 0;
}