Пример #1
0
static void test_machine(gconstpointer data)
{
    const char *machine = data;
    char *args;

    args = g_strdup_printf("-S -M %s", machine);
    qtest_start(args);

    test_info_commands();
    test_commands();

    qtest_end();
    g_free(args);
    g_free((void *)data);
}
Пример #2
0
/*---------------------------------------------------------------------+
|                               main                                   |
| ==================================================================== |
|                                                                      |
| Function:  Main program  (see prolog for more details)               |
|                                                                      |
| Returns:   (0)  Successful completion                                |
|            (-1) Error occurred                                       |
|                                                                      |
+---------------------------------------------------------------------*/
int main (int argc, char **argv)
{
	int	proc;			/* fork loop index */
	pid_t	pid;			/* Process id */
	int	status;			/* Child's exit status */

        /*
         * Parse command line arguments and print out program header
         */
        parse_args (argc, argv);
        printf ("%s: IPC Semaphore TestSuite program\n", *argv);
	fflush (stdout);
	parent_pid = getpid ();

	/*
	 * Fork off the additional processes.
	 */
	if (nprocs > 0) {
		printf ("\n\tParent: spawning %d child processes\n", nprocs);
		fflush (stdout);
	}
	for (proc = 1; proc < nprocs; proc++) {
		/*
		 * Child leaves loop, parent continues to fork.
		 */
	if ((pid = fork ()) < 0)
			error ("fork failed", __LINE__);
		else if (pid == 0)
			break;
		else
			childpid [proc] = pid;
	}
	pid = getpid();

        /*
         * Test the semget () and semctl () commands
         */
	test_commands (pid);

        /*
         * Finished testing commands, only parent process needs to continue
         */
        if (pid != parent_pid) exit (0);

        /*
         * Wait for all of the child processes to complete & check their
         * exit status.
         *
         * Upon completion of the child proccesses, exit program with success.
         */
        for (proc = 1; proc < nprocs; proc++) {
                waitpid (childpid [proc], &status, 0);

                if (!WIFEXITED (status))
                        error ("child process terminated abnormally",
                                __LINE__);
        }
	if (nprocs > 0)
		printf ("\n\tAll child processes verified commands successfully\n");
        printf ("\nsuccessful!\n");
	return (errors);
}