コード例 #1
0
int
main(int argc, const char **argv)
{
	set_debug_flags(NULL, D_ALWAYS);

	set_mySubSystem( "TEST_LOG_READER_STATE", SUBSYSTEM_TYPE_TOOL );

		// initialize to read from config file
	myDistro->Init( argc, argv );
	config();

		// Set up the dprintf stuff...
	dprintf_config("TEST_LOG_READER_STATE");

	Options	opts;
	if ( CheckArgs( argc, argv, opts ) < 0 ) {
		fprintf( stderr, "CheckArgs() failed\n" );
		exit( 1 );
	}

	ReadUserLog::FileState	state;
	if ( opts.needStateFile() && ( ReadState( opts, state ) < 0 )  ) {
		fprintf( stderr, "ReadState() failed\n" );
		exit( 1 );
	}
	ReadUserLog::FileState	state2;
	if ( opts.needStateFile2() && ( ReadState( opts, state2 ) < 0 )  ) {
		fprintf( stderr, "ReadState() failed\n" );
		exit( 1 );
	}

	int	status = 0;
	switch( opts.getCommand() )
	{
	case CMD_NONE:
		status = -1;
		break;
	case CMD_LIST:
		opts.dumpFieldList( );
		break;
	case CMD_DUMP:
		status = DumpState( opts, state );
		break;
	case CMD_DIFF:
		status = DiffState( opts, state, state2 );
		break;
	case CMD_ACCESS:
		status = CheckStateAccess( opts, state );
		break;
	case CMD_VERIFY:
		status = VerifyState( opts, state );
		break;
	}

	if ( status == 0 ) {
		exit( 0 );
	} else {
		exit( 2 );
	}
}
コード例 #2
0
ファイル: spellchk.c プロジェクト: Adam-K-P/School-work
void scan_options (int argc, char** argv, char **default_dictionary,
                   char **user_dictionary) {
   // Scan the arguments and set flags.
   opterr = false;
   for (;;) {
      int option = getopt (argc, argv, "nxyd:@:");
      if (option == EOF) break;
      switch (option) {
         char optopt_string[16]; // used in default:
         case 'd': *user_dictionary = optarg;
                   break;
         case 'n': *default_dictionary = NULL;
                   break;
         case 'x': x = true; 
                   break;
         case 'y': yy_flex_debug = true;
                   break;
         case '@': set_debug_flags (optarg);
                   if (strpbrk (optarg, "@y")) yy_flex_debug = true;
                   break;
         default : sprintf (optopt_string, "-%c", optopt);
                   print_error (optopt_string, "invalid option");
                   break;
      }
   }
}
コード例 #3
0
ファイル: cron.c プロジェクト: BackupTheBerlios/hc-cron
static void
parse_args (int argc, char *argv[], int *const pass_environment_p,
	    char **const config_file_p)
{
  int argch;

  /*Set defaults */
  *pass_environment_p = 0;

#ifdef CONFIG_FILE
  *config_file_p = CONFIG_FILE;
#else
  *config_file_p = NULL;
#endif

  while (EOF != (argch = getopt (argc, argv, "ef:x:")))
    {
      switch (argch)
	{
	case 'f':
	  *config_file_p = optarg;
	  break;
	case 'e':
	  pass_environment = 1;
	  break;
	case 'x':
	  if (!set_debug_flags (optarg))
	    usage ();
	  break;
	default:
	  usage ();
	}
    }
}
コード例 #4
0
int
main(int argc, char **argv)
{
    // Set up the dprintf stuff...
    Termlog = true;
    dprintf_config("test_write_term", get_param_functions());
    set_debug_flags(NULL, D_ALWAYS);

    int		result = 0;

    Arguments	args;

    Status tmpStatus = CheckArgs(argc, argv, args);

    if ( tmpStatus == STATUS_OK ) {
        result = WriteTermEvent(args);
    } else if ( tmpStatus == STATUS_ERROR ) {
        result = 1;
    }

    if ( args.writeExec && (tmpStatus == STATUS_OK) && (result == 0) ) {
        result = WriteExecEvent(args);
    }

    if ( result != 0 ) {
        fprintf(stderr, "test_write_term FAILED\n");
    }

    return result;
}
コード例 #5
0
ファイル: agent_helper.c プロジェクト: carriercomm/zetascale
/**
 * @brief Pre-initialization of SDF agent engine (pthread safe)
 *
 * 0. argument parsing, <br>
 * 1. read and initialize properties <br>
 * 2. calls agent_engine_pre_init_internal <br>
 *
 * @return status, SDF_TRUE on success
 */
SDF_boolean_t agent_engine_pre_init(struct sdf_agent_state *state, int argc, char *argv[])
{
    SDF_boolean_t  success = SDF_TRUE;
    const char    *sdf_mode_string;
    const char    *sdf_replication_string;

    if (success) {
        success = plat_opts_parse_sdf_agent(&state->config, argc, argv) ?
                  SDF_FALSE : SDF_TRUE;
        plat_log_msg(20849, LOG_CAT,
                     success ?  LOG_LEV : PLAT_LOG_LEVEL_DEBUG,
                     "plat_opts_parse_sdf_agent SUCCESS = %u", success);
    }

    if (success) {
        success = agent_config_set_properties(&state->config);
        plat_log_msg(20850, LOG_CAT,
                     success ? LOG_LEV : PLAT_LOG_LEVEL_DEBUG,
                     "set properties SUCCESS = %u", success);
    }

    if (success && !state->config.log_less) {
        set_debug_flags();
    }

    /*  Determine if we are in "new" mode, so that we don't
     *  start up unnecessary subsystems.
     */

    sdf_mode_string = getProperty_String("SDF_MODE", "new");

    if (strcmp(sdf_mode_string, "new") == 0) {
        SDFNew_Mode = SDF_TRUE;
    } else {
        SDFNew_Mode = SDF_FALSE;
    }

    /*  Determine if replication is turned on.
     */

    sdf_replication_string = getProperty_String("SDF_REPLICATION", "Off");

    if (strcmp(sdf_replication_string, "On") == 0) {
        SDFEnable_Replication = SDF_TRUE;
    } else {
        sdf_replication_string = getProperty_String("SDF_SIMPLE_REPLICATION", "Off");
        if (strcmp(sdf_replication_string, "On") == 0) {
            SDFEnable_Replication = SDF_TRUE;
        } else {
            SDFEnable_Replication = SDF_FALSE;
        }
    }

    if (success) {
        success = agent_engine_pre_init_internal(state, argc, argv);
    }

    return (success);
}
コード例 #6
0
int
main(int argc, char** argv)
{
	int retval = 0;
	Termlog = 1;
	dprintf_config("TOOL", get_param_functions());

	set_debug_flags(0, D_ALWAYS);
	config();
	retval = sysapi_test_dump_all(argc, argv);
	printf("Failed tests = %d\n",retval);
	return (retval);
}
コード例 #7
0
ファイル: main.c プロジェクト: Adam-K-P/School-work
void scan_options (int argc, char **argv) {
   opterr = false;
   for (;;) {
      int option = getopt (argc, argv, "@:");
      if (option == EOF) break;
      switch (option) {
         case '@': set_debug_flags (optarg);
                   break;
         default : printf ("%s: -%c: invalid option\n",
                           program_name, optopt);
                   break;
      }
   }
}
コード例 #8
0
ファイル: cron.c プロジェクト: enukane/netbsd-src
static void
parse_args(int argc, char *argv[]) {
	int argch;

	while (-1 != (argch = getopt(argc, argv, "nx:"))) {
		switch (argch) {
		default:
			usage();
			break;
		case 'x':
			if (!set_debug_flags(optarg))
				usage();
			break;
		case 'n':
			NoFork = 1;
			break;
		}
	}
}
コード例 #9
0
ファイル: perm.WINDOWS.cpp プロジェクト: AmesianX/htcondor
// Main method for testing the Perm functions
int 
main(int argc, char* argv[]) {
	
	char *filename, *domain, *username;
	perm* foo = new perm();

	DebugFP = stdout;
	set_debug_flags( "D_ALL", 0 );
	//char p_ntdomain[80];
	//char buf[100];
	
	if (argc < 4) { 
		cout << "Usage:\nperm filename domain username" << endl;
		return (1);
	}
	filename = argv[1];
	domain = argv[2];
	username = argv[3];
	
	foo->init(username, domain);
	
	cout << "Checking write access for " << filename << endl;
	
	int result = foo->write_access(filename);
	
	if ( result == 1) {
		cout << "You can write to " << filename << endl;
	}
	else if (result == 0) {
		cout << "You are not allowed to write to " << filename << endl;
	}
	else if (result == -1) {
		cout << "An error has occured\n";
	}
	else {
		cout << "Ok you're screwed" << endl;
	}
	delete foo;
	return(0);
}
コード例 #10
0
int
Options::handleOpt( SimpleArg &arg, int &argno )
{
    if ( arg.Match('n', "numeric") ) {
        m_numeric = true;

    } else if ( arg.Match('d', "debug") ) {
        if ( arg.hasOpt() ) {
            set_debug_flags( const_cast<char *>(arg.getOpt()), 0 );
            argno = arg.ConsumeOpt( );
        } else {
            fprintf(stderr, "Value needed for '%s'\n", arg.Arg() );
            printf("%s", m_usage);
            return -1;
        }

    } else if ( arg.Match('v') ) {
        m_verbose++;

    } else if ( arg.Match("verbosity") ) {
        if ( !arg.getOpt( m_verbose ) ) {
            fprintf(stderr, "Value needed for '%s'\n", arg.Arg() );
            printf("%s", m_usage);
            return -1;
        }

    } else if ( arg.Match("version") ) {
        printf("test_log_reader_state: %s, %s\n", VERSION, __DATE__);
        return 1;
    }
    else {
        fprintf(stderr, "Unrecognized argument: '%s'\n", arg.Arg() );
        printf("%s", m_usage);
        return -1;
    }
    return 0;
}
コード例 #11
0
Status
CheckArgs(int argc, char **argv)
{
	Status	status = STATUS_OK;

	const char *	usage = "Usage: test_check_events [options]\n"
			"  -debug <level>: debug level (e.g., D_FULLDEBUG)\n"
			"  -usage: print this message and exit\n"
			"  -version: print the version number and compile date\n";

	for ( int index = 1; index < argc; ++index ) {
		if ( !strcmp(argv[index], "-debug") ) {
			if ( ++index >= argc ) {
				fprintf(stderr, "Value needed for -debug argument\n");
				printf("%s", usage);
				status = STATUS_ERROR;
			} else {
				set_debug_flags( argv[index], 0 );
			}

		} else if ( !strcmp(argv[index], "-usage") ) {
			printf("%s", usage);
			status = STATUS_CANCEL;

		} else if ( !strcmp(argv[index], "-version") ) {
			printf("test_check_events: %s, %s\n", VERSION, __DATE__);
			status = STATUS_CANCEL;

		} else {
			fprintf(stderr, "Unrecognized argument: <%s>\n", argv[index]);
			printf("%s", usage);
			status = STATUS_ERROR;
		}
	}

	return status;
}
コード例 #12
0
int
main( int argc, char ** const argv )
{
#ifndef WIN32
	/* Add the signals we want unblocked into sigSet */
	sigset_t sigSet;
	struct sigaction act;

	sigemptyset( &sigSet );
	sigaddset(&sigSet,SIGTERM);
	sigaddset(&sigSet,SIGQUIT);
	sigaddset(&sigSet,SIGPIPE);

	/* Set signal handlers */
	sigemptyset(&act.sa_mask);  /* do not block anything in handler */
	act.sa_flags = 0;

	/* Signals which should cause us to exit with status = signum */
	act.sa_handler = quit_on_signal;
	sigaction(SIGTERM,&act,0);
	sigaction(SIGQUIT,&act,0);
	sigaction(SIGPIPE,&act,0);

	/* Unblock signals in our set */
	sigprocmask( SIG_UNBLOCK, &sigSet, NULL );
#endif

	set_mySubSystem("AMAZON_GAHP", SUBSYSTEM_TYPE_GAHP);

	int min_workers = MIN_NUMBER_WORKERS;
	int max_workers = -1;
	const char * dprintfName = "EC2_GAHP";

	int c = 0;
	while ( (c = my_getopt(argc, argv, "l:f:d:w:m:" )) != -1 ) {
		switch(c) {
			case 'l':
				if( my_optarg && *my_optarg ) {
					dprintfName = my_optarg;
				}
				break;
			case 'f':
				break;
			case 'd':
				// Debug Level
				if( my_optarg && *my_optarg ) {
					set_debug_flags(my_optarg, 0);
				}
				break;
			case 'w':
				// Minimum number of worker pools
				min_workers = atoi(my_optarg);
				if( min_workers < MIN_NUMBER_WORKERS ) {
					min_workers = MIN_NUMBER_WORKERS;
				}
				break;
			case 'm':
				// Maximum number of worker pools
				max_workers = atoi(my_optarg);
				if( max_workers <= 0 ) {
					max_workers = -1;
				}
				break;
			default:
				usage();
		}
	}

    config();
    dprintf_config( dprintfName );
    const char * debug_string = getenv( "DebugLevel" );
    if( debug_string && * debug_string ) {
        set_debug_flags( debug_string, 0 );
    }

	dprintf(D_FULLDEBUG, "Welcome to the EC2 GAHP\n");

	const char *buff;

	//Try to read env for amazon_http_proxy
	buff = getenv(AMAZON_HTTP_PROXY);
	if( buff && *buff ) {
		set_amazon_proxy_server(buff);
		dprintf(D_ALWAYS, "Using http proxy = %s\n", buff);
	}

	// Register all amazon commands
	if( registerAllAmazonCommands() == false ) {
		dprintf(D_ALWAYS, "Can't register Amazon Commands\n");
		exit(1);
	}

	// Create IOProcess class
	ioprocess = new IOProcess;
	ASSERT(ioprocess);

	if( ioprocess->startUp(REQUEST_INBOX, min_workers, max_workers) == false ) {
		dprintf(D_ALWAYS, "Failed to start IO Process\n");
		delete ioprocess;
		exit(1);
	}

	// Print out the GAHP version to the screen
	// now we're ready to roll
	printf ("%s\n", version);
	fflush(stdout);

	dprintf( D_ALWAYS, "EC2 GAHP initialized\n" );

		/* Our main thread should grab the mutex first.  We will then
		 * release it and let other threads run when we would otherwise
		 * block.
		 */
	amazon_gahp_grab_big_mutex();

	for(;;) {
		ioprocess->stdinPipeHandler();
	}

	return 0;
}
コード例 #13
0
int main(int argc, char **argv)
{
	int		result = 0;

	if ( argc <= 1 || (argc >= 2 && !strcmp("-usage", argv[1])) ) {
		printf("Usage: condor_check_userlogs <log file 1> "
				"[log file 2] ... [log file n]\n");
		exit(0);
	}

		// Set up dprintf.
	dprintf_set_tool_debug("condor_check_userlogs", 0);
	set_debug_flags(NULL, D_ALWAYS);

	StringList	logFiles;
	for ( int argnum = 1; argnum < argc; ++argnum ) {
		logFiles.append(argv[argnum]);
	}
	logFiles.rewind();

	ReadMultipleUserLogs	ru;
	char *filename;
	while ( (filename = logFiles.next()) ) {
		MyString filestring( filename );
		CondorError errstack;
		if ( !ru.monitorLogFile( filestring, false, errstack ) ) {
			fprintf( stderr, "Error monitoring log file %s: %s\n", filename,
						errstack.getFullText().c_str() );
			result = 1;
		}
	}

	bool logsMissing = false;

	CheckEvents		ce;
	int totalSubmitted = 0;
	int netSubmitted = 0;
	bool done = false;
	while( !done ) {

    	ULogEvent* e = NULL;
		MyString errorMsg;

        ULogEventOutcome outcome = ru.readEvent( e );

        switch (outcome) {

        case ULOG_RD_ERROR:
        case ULOG_UNK_ERROR:
			logsMissing = true;
        case ULOG_NO_EVENT:

			printf( "Log outcome: %s\n", ULogEventOutcomeNames[outcome] );
			done = true;
			break;
 
        case ULOG_OK:

			printf( "Log event: %s (%d.%d.%d)",
						ULogEventNumberNames[e->eventNumber],
						e->cluster, e->proc, e->subproc );

			if ( ce.CheckAnEvent(e, errorMsg) != CheckEvents::EVENT_OKAY ) {
				fprintf(stderr, "%s\n", errorMsg.Value());
				result = 1;
			}

			if( e->eventNumber == ULOG_SUBMIT ) {
				SubmitEvent* ee = (SubmitEvent*) e;
				printf( " (\"%s\")", ee->submitEventLogNotes );
				++totalSubmitted;
				++netSubmitted;
				printf( "\n Total submitted: %d; net submitted: %d\n",
						totalSubmitted, netSubmitted );
			}
			
			if( e->eventNumber == ULOG_JOB_HELD ) {
				JobHeldEvent* ee = (JobHeldEvent*) e;
				printf( " (code=%d subcode=%d)", ee->getReasonCode(),
						ee->getReasonSubCode());
			}

			if( e->eventNumber == ULOG_JOB_TERMINATED ) {
				--netSubmitted;
				printf( "\n Total submitted: %d; net submitted: %d\n",
						totalSubmitted, netSubmitted );
			}

			if( e->eventNumber == ULOG_JOB_ABORTED ) {
				--netSubmitted;
				printf( "\n Total submitted: %d; net submitted: %d\n",
						totalSubmitted, netSubmitted );
			}

			if( e->eventNumber == ULOG_EXECUTABLE_ERROR ) {
				--netSubmitted;
				printf( "\n Total submitted: %d; net submitted: %d\n",
						totalSubmitted, netSubmitted );
			}

			printf( "\n" );
			break;

		default:

			fprintf(stderr, "Unexpected read event outcome!\n");
			result = 1;
			break;
        }
	}

	logFiles.rewind();
	while ( (filename = logFiles.next()) ) {
		MyString filestring( filename );
		CondorError errstack;
		if ( !ru.unmonitorLogFile( filestring, errstack ) ) {
			fprintf( stderr, "Error unmonitoring log file %s: %s\n", filename,
						errstack.getFullText().c_str() );
			result = 1;
		}
	}

	MyString errorMsg;
	CheckEvents::check_event_result_t checkAllResult =
				ce.CheckAllJobs(errorMsg);
	if ( checkAllResult != CheckEvents::EVENT_OKAY ) {
		fprintf(stderr, "%s\n", errorMsg.Value());
		fprintf(stderr, "CheckAllJobs() result: %s\n",
					CheckEvents::ResultToString(checkAllResult));
		result = 1;
	}

	if ( result == 0 ) {
		if ( !logsMissing ) {
			printf("Log(s) are okay\n");
		} else {
			printf("Log(s) may be okay\n");
			printf(  "Some logs cannot be read\n");
		}
	} else {
		printf("Log(s) have error(s)\n");
	}
	return result;
}
コード例 #14
0
ファイル: test.cpp プロジェクト: AlainRoy/htcondor
/* the main entry function, this will do all the magic */
extern "C" int
sysapi_test_dump_all(int argc, char** argv)
{
	int foo;
	int return_val = 0;
	int	tests = TEST_NONE;
	int failed_tests = 0;
	int passed_tests = 0;
	int i;
	int print_help = 0;
#if defined(LINUX)
	const char *linux_cpuinfo_file = NULL;
	int			linux_cpuinfo_debug = 0;
	const char *linux_uname = NULL;
	int 		linux_num = -1;
	int			linux_processors = -1;
	int			linux_hthreads = -1;
	int			linux_hthreads_core = -1;
	int			linux_cpus = -1;
#endif
	int ncpus_trials = NCPUS_TRIALS;
	int skip = 0;
	const char *free_fs_dir = "/tmp";

	if (argc <= 1)
		tests = TEST_ALL;
	for (i=1; i<argc; i++) {
		if ( skip ) {
			skip--;
			continue;
		}
		if (strcmp(argv[i], "--arch") == 0)
			tests |= ARCH;
		else if (strcmp(argv[i], "--kern_memmod") == 0)
			tests |= KERN_MEMMOD;
		else if (strcmp(argv[i], "--kern_vers") == 0)
			tests |= KERN_VERS;
		else if (strcmp(argv[i], "--ckptpltfrm") == 0)
			tests |= CKPTPLTFRM;
		else if (strcmp(argv[i], "--dump") == 0)
			tests |= DUMP;
		else if (strcmp(argv[i], "--free_fs_blocks") == 0) {
			tests |= FREE_FS_BLOCKS;
			if (  ( i+1 < argc ) &&
				  ( (*argv[i+1] == '/') || (*argv[i+1] == '.') )  ) {
				skip = 1;
				free_fs_dir = argv[i+1];
			}
		}
		else if (strcmp(argv[i], "--idle_time") == 0)
			tests |= IDLE_TIME;
		else if (strcmp(argv[i], "--kflops") == 0)
			tests |= KFLOPS;
		else if (strcmp(argv[i], "--last_x_event") == 0)
			tests |= LAST_X_EVENT;
		else if (strcmp(argv[i], "--load_avg") == 0)
			tests |= LOAD_AVG;
		else if (strcmp(argv[i], "--mips") == 0)
			tests |= MIPS;
		else if (strcmp(argv[i], "--ncpus") == 0) {
			tests |= NCPUS;
		}
		else if (strcmp(argv[i], "--phys_mem") == 0)
			tests |= PHYS_MEM;
		else if (strcmp(argv[i], "--virt_mem") == 0)
			tests |= VIRT_MEM;
		else if ( (strcmp(argv[i], "--debug") == 0) && (i+1 < argc)  ) {
			set_debug_flags( argv[i+1], 0 );
			skip = 1;
		}
#	  if defined(LINUX)
		else if (strcmp(argv[i], "--proc_cpuinfo") == 0) {
			tests |= NCPUS;
			linux_cpuinfo_file = "/proc/cpuinfo";
			linux_cpuinfo_debug = 1;	// Turn on debugging
			linux_num = 0;
		}
		else if ( (strcmp(argv[i], "--cpuinfo_file") == 0) && (i+2 < argc)  ) {
			tests |= NCPUS;
			linux_cpuinfo_file = argv[i+1];
			linux_cpuinfo_debug = 1;	// Turn on debugging
			if ( isdigit( *argv[i+2] ) ) {
				linux_num = atoi( argv[i+2] );
			} else {
				linux_uname = argv[i+2];
			}
			skip = 2;
		}
#	  endif
		else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
			print_help = 1;
		else {
			printf("%s is not an understood option. ", argv[i]);
			print_help = 1;
		}

		if (print_help != 0) {
			printf("Please use zero or more or:\n");
			printf("--debug <D_xxx>\n");
			printf("--arch\n");
			printf("--kern_vers\n");
			printf("--kern_memmod\n");
			printf("--ckptpltfrm\n");
			printf("--dump\n");
			printf("--free_fs_blocks [dir]\n");
			printf("--idle_time\n");
			printf("--kflops\n");
			printf("--last_x_event\n");
			printf("--load_avg\n");
			printf("--mips\n");
			printf("--ncpus\n");
			printf("--phys_mem\n");
			printf("--virt_mem\n");
#		  if defined(LINUX)
			printf("--proc_cpuinfo\n");
			printf("--cpuinfo_file <file> <uname match string>|<cpuinfo #>\n");
#		  endif
			return 0;
		}
	}

	if ((tests & KERN_MEMMOD) == KERN_MEMMOD) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		dprintf(D_ALWAYS, "SysAPI: Kernel memory model: %s\n",
			sysapi_kernel_memory_model());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & KERN_VERS) == KERN_VERS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		dprintf(D_ALWAYS, "SysAPI: Kernel version: %s\n",
			sysapi_kernel_version());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & CKPTPLTFRM) == CKPTPLTFRM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		sysapi_ckptpltfrm();
		sysapi_test_dump_internal_vars();
		sysapi_reconfig();
		sysapi_test_dump_internal_vars();
		dprintf(D_ALWAYS, "SysAPI: Checkpoint platform: %s\n",
			sysapi_ckptpltfrm());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & DUMP) == DUMP) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		sysapi_test_dump_internal_vars();
		sysapi_reconfig();
		sysapi_test_dump_internal_vars();
		//sysapi_test_dump_functions();
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & ARCH) == ARCH) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN ARCH_TEST:\n");
		foo = 0;
		foo = arch_test(500);
		dprintf(D_ALWAYS, "SysAPI: END ARCH_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed ARCH_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed ARCH_TEST.\n\n");
			failed_tests++;
		}
	}


	if ((tests & FREE_FS_BLOCKS) == FREE_FS_BLOCKS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN FREE_FS_BLOCKS_TEST:\n");
		foo = 0;
		foo = free_fs_blocks_test(free_fs_dir,
								  FREEBLOCKS_TRIALS,
								  FREEBLOCKS_TOLERANCE,
								  FREEBLOCKS_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END FREE_FS_BLOCKS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed FREE_FS_BLOCKS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed FREE_FS_BLOCKS_TEST.\n\n");
			failed_tests++;
		}
	}
	

	if ((tests & IDLE_TIME) == IDLE_TIME) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN IDLE_TIME_TEST:\n");
		foo = 0;
		foo = idle_time_test(IDLETIME_TRIALS,
							 IDLETIME_INTERVAL,
							 IDLETIME_TOLERANCE,
							 IDLETIME_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END IDLE_TIME_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed IDLE_TIME_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed IDLE_TIME_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & KFLOPS) == KFLOPS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN KFLOPS_TEST:\n");
		foo = 0;
		foo = kflops_test(KFLOPS_TRIALS,
						  KFLOPS_MAX_SD_VAR,
						  KFLOPS_MAX_WARN_OK
						  );
		dprintf(D_ALWAYS, "SysAPI: END KFLOPS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed KFLOPS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed KFLOPS_TEST.\n\n");
			failed_tests++;
		}
	}


	if ((tests & LAST_X_EVENT) == LAST_X_EVENT) {
		dprintf(D_ALWAYS, "SysAPI: SKIPPING LASE_X_EVENT_TEST: internally used variable only.\n\n");
	}
	

	if ((tests & LOAD_AVG) == LOAD_AVG) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN LOAD_AVG_TEST:\n");
		foo = 0;
		foo = load_avg_test(LOADAVG_TRIALS,
							LOADAVG_INTERVAL,
							LOADAVG_CHILDREN,
							LOADAVG_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END LOAD_AVG_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed LOAD_AVG_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed LOAD_AVG_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & MIPS) == MIPS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN MIPS_TEST:\n");
		foo = 0;
		foo = mips_test(MIPS_TRIALS,
						MIPS_MAX_SD_VAR,
						MIPS_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END MIPS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed MIPS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed MIPS_TEST.\n\n");
			failed_tests++;
		}
	}
	
	/* Special test: /proc/cpuinfo on a file */
#if defined(LINUX)
	if ((tests & NCPUS) == NCPUS && linux_cpuinfo_file ) {
		bool is_proc_cpuinfo = false;

		/* set_debug_flags(NULL, D_FULLDEBUG); */
		if ( strcmp( linux_cpuinfo_file, "/proc/cpuinfo" ) == 0 ) {
			is_proc_cpuinfo = true;
			dprintf( D_ALWAYS, "Using the real /proc/cpuinfo\n" );
		}

		FILE	*fp = safe_fopen_wrapper_follow( linux_cpuinfo_file, "r", 0644 );
		if ( !fp ) {
			dprintf(D_ALWAYS, "SysAPI: Can't open cpuinfo file '%s'.\n\n",
					linux_cpuinfo_file);
			return(++failed_tests);
		}
		else {
			/* Skip 'til we find the "right" uname */
			char	buf[256];
			char	uname[256];
			int		found = 0;
			int		linenum = 1;
			int		cpuinfo_num = 0;		/* # of this cpuinfo block */

			if ( is_proc_cpuinfo ) {
				found = true;
				strcpy( uname, "" );
			}
			else {
				while( fgets( buf, sizeof(buf), fp) ) {
					linenum++;
					buf[sizeof(buf)-1] = '\0';
					if ( !strncmp( buf, "UNAME:", 6 ) && ( strlen(buf) > 6 ) ){
						cpuinfo_num++;
						if ( ( ( linux_num >= 0 ) &&
							   ( linux_num == cpuinfo_num ) ) ||
							 ( linux_uname &&
							   strstr( buf, linux_uname ) )   ) {
							strncpy( uname, buf+6, sizeof(uname) );
							found = linenum;
						}
					}
					else if ( found ) {
						if ( !strncmp( buf, "START", 5 ) && found ) {
							break;
						}
						sscanf( buf, "PROCESSORS: %d", &linux_processors );
						sscanf( buf, "HTHREADS: %d", &linux_hthreads );
						sscanf( buf, "HTHREADS_CORE: %d",
								&linux_hthreads_core );
					}
				}
			}

			// Store the current file position & file name
			_SysapiProcCpuinfo.file = linux_cpuinfo_file;
			_SysapiProcCpuinfo.debug = linux_cpuinfo_debug;
			_SysapiProcCpuinfo.offset = ftell( fp );
			fclose( fp );
			fp = NULL;

			// Calculate total "non-primary" hyper threads
			if ( ! is_proc_cpuinfo ) {
				if ( ( linux_hthreads < 0 )		  &&
					 ( linux_hthreads_core > 0 )  &&
					 ( linux_processors > 0 )  )  {
					linux_hthreads = (  linux_processors -
										( linux_processors /
										  linux_hthreads_core )  );
				}
			}

			// Calculate the total # of CPUs
			if ( linux_processors ) {
				if ( param_boolean_int("COUNT_HYPERTHREAD_CPUS", 1) ) {
					linux_cpus = linux_processors;
				}
				else {
					linux_cpus = linux_processors - linux_hthreads;
				}
			}

			if ( !found ) {
				if ( linux_num >= 0 ) {
					dprintf(D_ALWAYS,
							"SysAPI: Can't find uname # %d in %s.\n\n",
							linux_num, linux_cpuinfo_file );
				}
				else {
					dprintf(D_ALWAYS,
							"SysAPI: Can't find uname '%s' in %s.\n\n",
							linux_uname, linux_cpuinfo_file );
				}
				return(++failed_tests);
			}
			if ( strlen( uname ) ) {
				dprintf(D_ALWAYS,
						"SysAPI: Using uname string on line %d:\n%s\n",
						found, uname );
			}
			ncpus_trials = 1;
		}
	}
#endif

	if ((tests & NCPUS) == NCPUS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN NUMBER_CPUS_TEST:\n");
		foo = 0;
		foo = ncpus_test(ncpus_trials,
						 NCPUS_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END NUMBER_CPUS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed NUMBER_CPUS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed NUMBER_CPUS_TEST.\n\n");
			failed_tests++;
		}
#    if defined(LINUX)
		if ( ( linux_processors >= 0 ) &&
			 ( _SysapiProcCpuinfo.found_processors != linux_processors )  )  {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # Processors (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_processors,
					linux_processors );
		}
		if ( ( linux_hthreads >= 0 ) &&
			 ( _SysapiProcCpuinfo.found_hthreads != linux_hthreads ) ) {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # HyperThreads (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_hthreads,
					linux_hthreads );
		}
		if ( ( linux_cpus > 0 ) &&
			 ( _SysapiProcCpuinfo.found_ncpus != linux_cpus )  )    {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # CPUs (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_ncpus,
					linux_cpus );
		}
		int	level = D_FULLDEBUG;
		if (linux_cpuinfo_debug) {
			level = D_ALWAYS;
		}
		dprintf( level,
				 "SysAPI: Detected %d Processors, %d HyperThreads"
				 " => %d CPUS\n",
				 _SysapiProcCpuinfo.found_processors,
				 _SysapiProcCpuinfo.found_hthreads,
				 _SysapiProcCpuinfo.found_ncpus );
				
#    endif
	}
	

	if ((tests & PHYS_MEM) == PHYS_MEM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN PHYSICAL_MEMORY_TEST:\n");
		foo = 0;
		foo = phys_memory_test(PHYSMEM_TRIALS, PHYSMEM_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END PHYSICAL_MEMORY_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed PHYSICAL_MEMORY_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed PHYSICAL_MEMORY_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & VIRT_MEM) == VIRT_MEM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN VIRTUAL_MEMORY_TEST:\n");
		foo = 0;
		foo = virt_memory_test(VIRTMEM_TESTBLOCK_SIZE,
							   VIRTMEM_MAX_SD_VAR,
							   VIRTMEM_MAX_FAIL_OK);
		dprintf(D_ALWAYS, "SysAPI: END VIRTUAL_MEMORY_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed VIRTUAL_MEMORY_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed VIRTUAL_MEMORY_TEST.\n\n");
			failed_tests++;
		}
	}
	printf("Passed tests = %d\n",passed_tests);
	return(failed_tests);
}
コード例 #15
0
int
main(int argc, const char **argv)
{
	set_debug_flags(NULL, D_ALWAYS);

		// initialize to read from config file
	myDistro->Init( argc, argv );
	config();

		// Set up the dprintf stuff...
	Termlog = true;
	dprintf_config("TEST_NETWORK_ADAPTER", get_param_functions());

	const char	*tmp;
	int			 status = 0;
	Options		 opts;

	if ( CheckArgs(argc, argv, opts) ) {
		exit( 1 );
	}

	NetworkAdapterBase	*net = NULL;

	if ( opts.m_if_name ) {
		printf( "Creating network adapter object for name %s\n",
				opts.m_if_name );
		net = NetworkAdapterBase::createNetworkAdapter( opts.m_if_name );
	}
	else {
		MyString	sinful;
		sinful.formatstr( "<%s:1234>", opts.m_address );
		printf( "Creating network adapter object for %s\n", sinful.Value() );
		net = NetworkAdapterBase::createNetworkAdapter( sinful.Value() );
	}
	if ( !net ) {
		printf( "Error creating adapter\n" );
		exit(1);
	}

	// Initialize it
	if ( !net->getInitStatus() ) {
		printf( "Initialization of adaptor with address %s failed\n",
				opts.m_address );
		delete net;
		exit(1);
	}

	// And, check for it's existence
	if ( !net->exists() ) {
		printf( "Adaptor with address %s not found\n",
				opts.m_address );
		delete net;
		exit(1);
	}

	// Now, extract information from it
	tmp = net->hardwareAddress();
	if ( !tmp || !strlen(tmp) ) tmp = "<NONE>";
	printf( "hardware address: %s\n", tmp );

	tmp = net->subnetMask();
	if ( !tmp || !strlen(tmp) ) tmp = "<NONE>";
	printf( "subnet: %s\n", tmp );

	printf( "wakable: %s\n", net->isWakeable() ? "YES" : "NO" );

	MyString	tmpstr;
	net->wakeSupportedString( tmpstr );
	printf( "wake support flags: %s\n", tmpstr.Value() );

	net->wakeEnabledString( tmpstr );
	printf( "wake enable flags: %s\n", tmpstr.Value() );

	HibernatorBase	*hibernator = new RealHibernator( );
	if ( opts.m_method ) {
		printf( "Setting method to %s\n", opts.m_method );
		hibernator->setMethod( opts.m_method );
	}
	HibernationManager	hman( hibernator );
	if ( !hman.initialize( ) ) {
		fprintf( stderr, "Initialization of hibernation manager failed\n" );
		status = 1;
	}
	hman.addInterface( *net );

	ClassAd	ad;
	hman.publish( ad );
	ad.fPrint( stdout );

	const char	*method = hman.getHibernationMethod();
	printf( "Hibernation method used: %s\n", method );

	printf( "Can hibernate: %s\n", BoolString(hman.canHibernate()) );
	printf( "Can wake: %s\n", BoolString(hman.canWake()) );

	if ( hman.canHibernate() && opts.m_state != HibernatorBase::NONE ) {
		printf( "Setting state %s\n", hman.sleepStateToString(opts.m_state) );
		if ( ! hman.switchToState( opts.m_state ) ) {
			printf( "Failed to switch states\n" );
			status = 1;
		}
	}

	if ( status != 0 && opts.m_verbosity >= 1 ) {
		fprintf(stderr, "test_hibernation FAILED\n");
	}

	delete net;
	return status;
}
コード例 #16
0
int
main( int argc, char* argv[] )
{
	int		i;
	param_functions *p_funcs = NULL;
	
	set_mySubSystem( "DAEMON-TOOL", SUBSYSTEM_TYPE_TOOL );

	MyName = argv[0];
	myDistro->Init( argc, argv );

	FILE *input_fp = stdin;

	for( i=1; i<argc; i++ ) {
		if( match_prefix( argv[i], "-daemontype" ) ) {
			if( argv[i + 1] ) {
				get_mySubSystem()->setName( argv[++i] );
				get_mySubSystem()->setTypeFromName( );
			} else {
				usage();
			}
		} else if( match_prefix( argv[i], "-debug" ) ) {
				// dprintf to console
			Termlog = 1;
			p_funcs = get_param_functions();
			dprintf_config( "DAEMON-TOOL", p_funcs );
			set_debug_flags(NULL, D_FULLDEBUG|D_SECURITY);
		} else if( match_prefix( argv[i], "-" ) ) {
			usage();
		} else {
			usage();
		}
	}

	// If we didn't get told what subsystem we should use, set it
	// to "TOOL".

	if( !get_mySubSystem()->isNameValid() ) {
		get_mySubSystem()->setName( "DAEMON-TOOL" );
	}

	config( 0, true );

	IpVerify ipverify;

	MyString line;
	while( line.readLine(input_fp) ) {
		line.chomp();
		if( line.IsEmpty() || line[0] == '#' ) {
			printf("%s\n",line.Value());
			continue;
		}

		StringList fields(line.Value()," ");
		fields.rewind();

		char const *perm_str = fields.next();
		char const *fqu = fields.next();
		char const *ip = fields.next();
		char const *expected = fields.next();

		MyString sin_str = generate_sinful(ip, 0);

		condor_sockaddr addr;
		if( !addr.from_sinful(sin_str) ) {
			fprintf(stderr,"Invalid ip address: %s\n",ip);
			exit(1);
		}

		DCpermission perm = StringToDCpermission(perm_str);
		if( perm == LAST_PERM ) {
			fprintf(stderr,"Invalid permission level: %s\n",perm_str);
			exit(1);
		}

		if( strcmp(fqu,"*") == 0 ) {
			fqu = "";
		}

		char const *result;
		MyString reason;
		if( ipverify.Verify(perm,addr,fqu,&reason,&reason) != USER_AUTH_SUCCESS ) {
			result = "DENIED";
		}
		else {
			result = "ALLOWED";
		}

		if( expected && strcasecmp(expected,result) != 0 ) {
			printf("Got wrong result '%s' for '%s': reason: %s!\n",
				   result,line.Value(),reason.Value());
			printf("Aborting.\n");
			exit(1);
		}
		if( expected ) {
			printf("%s\n",line.Value());
		}
		else {
			printf("%s %s\n",line.Value(),result);
		}
	}
}
コード例 #17
0
//---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
	param_functions *p_funcs = NULL;
	printf("\n");

		// Set up the dprintf stuff to write to stderr, so that Condor
		// libraries which use it will write to the right place...
	Termlog = true;
	p_funcs = get_param_functions();
	dprintf_config("condor_submit_dag", p_funcs); 
	set_debug_flags(NULL, D_ALWAYS | D_NOHEADER);
	config();

		// Initialize our Distribution object -- condor vs. hawkeye, etc.
	myDistro->Init( argc, argv );

		// Load command-line arguments into the deepOpts and shallowOpts
		// structures.
	SubmitDagDeepOptions deepOpts;
	SubmitDagShallowOptions shallowOpts;
	parseCommandLine(deepOpts, shallowOpts, argc, argv);

	int tmpResult;

		// Recursively run ourself on nested DAGs.  We need to do this
		// depth-first so all of the lower-level .condor.sub files already
		// exist when we check for log files.
	if ( deepOpts.recurse ) {
		tmpResult = doRecursion( deepOpts, shallowOpts );
		if ( tmpResult != 0) {
			fprintf( stderr, "Recursive submit(s) failed; exiting without "
						"attempting top-level submit\n" );
			return tmpResult;
		}
	}
	
		// Further work to get the shallowOpts structure set up properly.
	tmpResult = setUpOptions( deepOpts, shallowOpts );
	if ( tmpResult != 0 ) return tmpResult;

		// Check whether the output files already exist; if so, we may
		// abort depending on the -f flag and whether we're running
		// a rescue DAG.
	ensureOutputFilesExist( deepOpts, shallowOpts );

		// Make sure that all node jobs have log files, the files
		// aren't on NFS, etc.

		// Note that this MUST come after recursion, otherwise we'd
		// pass down the "preserved" values from the current .condor.sub
		// file.
	if ( deepOpts.updateSubmit ) {
		tmpResult = getOldSubmitFlags( shallowOpts );
		if ( tmpResult != 0 ) return tmpResult;
	}

		// Write the actual submit file for DAGMan.
	writeSubmitFile( deepOpts, shallowOpts );

	return submitDag( shallowOpts );
}
コード例 #18
0
ファイル: crontab.c プロジェクト: VargMon/netbsd-cvs-mirror
static void
parse_args(int argc, char *argv[]) {
	int argch;

	if (!(pw = getpwuid(getuid()))) {
		errx(ERROR_EXIT,
		    "your UID isn't in the passwd file. bailingo out");
	}
	if (strlen(pw->pw_name) >= sizeof User) {
		errx(ERROR_EXIT, "username too long");
	}
	(void)strlcpy(User, pw->pw_name, sizeof(User));
	(void)strlcpy(RealUser, User, sizeof(RealUser));
	Filename[0] = '\0';
	Option = opt_unknown;
	while (-1 != (argch = getopt(argc, argv, getoptargs))) {
		switch (argch) {
#if DEBUGGING
		case 'x':
			if (!set_debug_flags(optarg))
				usage("bad debug option");
			break;
#endif
		case 'u':
			if (MY_UID(pw) != ROOT_UID) {
				errx(ERROR_EXIT,
				    "must be privileged to use -u");
			}
			if (!(pw = getpwnam(optarg))) {
				errx(ERROR_EXIT, "user `%s' unknown", optarg);
			}
			if (strlen(optarg) >= sizeof User)
				usage("username too long");
			(void) strlcpy(User, optarg, sizeof(User));
			break;
		case 'l':
			if (Option != opt_unknown)
				usage("only one operation permitted");
			Option = opt_list;
			break;
		case 'r':
			if (Option != opt_unknown)
				usage("only one operation permitted");
			Option = opt_delete;
			break;
		case 'e':
			if (Option != opt_unknown)
				usage("only one operation permitted");
			Option = opt_edit;
			break;
		default:
			usage("unrecognized option");
		}
	}

	endpwent();

	if (Option != opt_unknown) {
		if (argv[optind] != NULL)
			usage("no arguments permitted after this option");
	} else {
		if (argv[optind] != NULL) {
			Option = opt_replace;
			if (strlen(argv[optind]) >= sizeof Filename)
				usage("filename too long");
			(void)strlcpy(Filename, argv[optind], sizeof(Filename));
		} else
			usage("file name must be specified for replace");
	}

	if (Option == opt_replace) {
		/* we have to open the file here because we're going to
		 * chdir(2) into /var/cron before we get around to
		 * reading the file.
		 */
		if (!strcmp(Filename, "-"))
			NewCrontab = stdin;
		else {
			/* relinquish the setuid status of the binary during
			 * the open, lest nonroot users read files they should
			 * not be able to read.  we can't use access() here
			 * since there's a race condition.  thanks go out to
			 * Arnt Gulbrandsen <*****@*****.**> for spotting
			 * the race.
			 */

			if (relinguish_priv() < OK) {
				err(ERROR_EXIT, "swapping uids");
			}
			if (!(NewCrontab = fopen(Filename, "r"))) {
				err(ERROR_EXIT, "cannot open `%s'", Filename);
			}
			if (regain_priv() < OK) {
				err(ERROR_EXIT, "swapping uids back");
			}
		}
	}

	Debug(DMISC, ("user=%s, file=%s, option=%s\n",
		      User, Filename, Options[(int)Option]));
}
コード例 #19
0
//---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
	printf("\n");

		// Set up the dprintf stuff to write to stderr, so that Condor
		// libraries which use it will write to the right place...
	dprintf_set_tool_debug("TOOL", 0);
	set_debug_flags(NULL, D_ALWAYS | D_NOHEADER);
	config();

		// Initialize our Distribution object -- condor vs. hawkeye, etc.
	myDistro->Init( argc, argv );

		// Load command-line arguments into the deepOpts and shallowOpts
		// structures.
	SubmitDagDeepOptions deepOpts;
	SubmitDagShallowOptions shallowOpts;

		// We're setting strScheddDaemonAdFile and strScheddAddressFile
		// here so that the classad updating feature (see gittrac #1782)
		// works properly.  The problem is that the schedd daemon ad and
		// address files are normally defined relative to the $LOG value.
		// Because we specify a different log directory on the condor_dagman
		// command line, if we don't set the values here, condor_dagman
		// won't be able to find those files when it tries to communicate
		/// with the schedd.  wenger 2013-03-11
	shallowOpts.strScheddDaemonAdFile = param( "SCHEDD_DAEMON_AD_FILE" );
	shallowOpts.strScheddAddressFile = param( "SCHEDD_ADDRESS_FILE" );
	parseCommandLine(deepOpts, shallowOpts, argc, argv);

	int tmpResult;

		// Recursively run ourself on nested DAGs.  We need to do this
		// depth-first so all of the lower-level .condor.sub files already
		// exist when we check for log files.
	if ( deepOpts.recurse ) {
		if ( param_boolean( "DAGMAN_USE_OLD_DAG_READER", false ) ) {
			fprintf( stderr, "Warning: DAGMAN_USE_OLD_DAG_READER "
						"is no longer supported\n" );
		}
		tmpResult = doRecursionNew( deepOpts, shallowOpts );
		if ( tmpResult != 0) {
			fprintf( stderr, "Recursive submit(s) failed; exiting without "
						"attempting top-level submit\n" );
			return tmpResult;
		}
	}
	
		// Further work to get the shallowOpts structure set up properly.
	tmpResult = setUpOptions( deepOpts, shallowOpts );
	if ( tmpResult != 0 ) return tmpResult;

		// Check whether the output files already exist; if so, we may
		// abort depending on the -f flag and whether we're running
		// a rescue DAG.
	ensureOutputFilesExist( deepOpts, shallowOpts );

		// Make sure that all node jobs have log files, the files
		// aren't on NFS, etc.

		// Note that this MUST come after recursion, otherwise we'd
		// pass down the "preserved" values from the current .condor.sub
		// file.
	if ( deepOpts.updateSubmit ) {
		tmpResult = getOldSubmitFlags( shallowOpts );
		if ( tmpResult != 0 ) return tmpResult;
	}

		// Write the actual submit file for DAGMan.
	writeSubmitFile( deepOpts, shallowOpts );

	return submitDag( shallowOpts );
}
コード例 #20
0
bool
CheckArgs(int argc, const char **argv, Options &opts)
{
	const char *	usage =
		"Usage: test_hibernation [options] <IP address|IF name> [state]\n"
		"  -d|--debug <level>: debug level (e.g., D_FULLDEBUG)\n"
		"  --usage|--help|-h: print this message and exit\n"
		"  -m|--method: specify Linux hibernation method to use\n"
		"  -v: Increase verbosity level by 1\n"
		"  --verbosity <number>: set verbosity level (default is 1)\n"
		"  --version: print the version number and compile date\n";

	opts.m_if_name = NULL;
	opts.m_address = "127.0.0.1";

	opts.m_method = NULL;

	opts.m_state = HibernatorBase::NONE;
	opts.m_verbosity = 1;

	int		fixed = 0;
	for ( int index = 1; index < argc; ) {
		SimpleArg	arg( argv, argc, index );

		if ( arg.Error() ) {
			printf("%s", usage);
			return true;
		}

		if ( arg.Match( 'd', "debug") ) {
			if ( arg.hasOpt() ) {
				set_debug_flags( arg.getOpt(), 0 );
			} else {
				fprintf(stderr, "Value needed for %s\n", arg.Arg() );
				printf("%s", usage);
				return true;
			}
		}
		else if ( ( arg.Match("usage") )	||
				  ( arg.Match('h') )		||
				  ( arg.Match("help") ) )	{
			printf("%s", usage);
			return true;
		}
		else if ( arg.Match('v') ) {
			opts.m_verbosity++;
		}
		else if ( arg.Match("verbosity") ) {
			if ( ! arg.getOpt(opts.m_verbosity) ) {
				fprintf(stderr, "Value needed for %s\n", arg.Arg() );
				printf("%s", usage);
				return true;
			}
		}
		else if ( arg.Match("version") ) {
			printf("test_hibernation: %s, %s\n", VERSION, __DATE__);
			return true;
		}
		else if ( arg.Match('m', "method") ) {
			if ( !arg.getOpt(opts.m_method) ) {
				fprintf(stderr, "Value needed for %s\n", arg.Arg() );
				printf("%s", usage);
				return true;
			}
		}
		else if ( !arg.ArgIsOpt()  &&  (fixed == 0)  &&  arg.isOptInt() ) {
			fixed++;
			opts.m_address = arg.getOpt();
		}
		else if ( !arg.ArgIsOpt()  &&  (fixed == 0) ) {
			opts.m_if_name = arg.getOpt();
			fixed++;
		}
		else if ( !arg.ArgIsOpt() && (fixed == 1) ) {
			fixed++;
			const char *s = arg.getOpt();
			opts.m_state = HibernatorBase::stringToSleepState( s );
			if ( opts.m_state == HibernatorBase::NONE ) {
				fprintf( stderr, "Unknown state '%s'\n", s );
				return true;
			}
		}
		else {
			fprintf(stderr, "Unrecognized argument: <%s>\n", arg.Arg() );
			printf("%s", usage);
			return true;
		}
		index = arg.Index();
	}

	return false;
}
コード例 #21
0
ファイル: crontab.c プロジェクト: BackupTheBerlios/hc-cron
static void
parse_args (int argc, char *argv[], char **const config_file_p)
{
  int argch;

#ifdef CONFIG_FILE
  *config_file_p = CONFIG_FILE;
#else
  *config_file_p = NULL;
#endif

  if (!(pw = getpwuid (getuid ())))
    {
      fprintf (stderr, "%s: your UID isn't in the passwd file.\n",
	       ProgramName);
      fprintf (stderr, "bailing out.\n");
      exit (ERROR_EXIT);
    }
  strncpy (User, pw->pw_name, MAX_UNAME-1);
  strncpy (RealUser, User, MAX_UNAME);
  Filename[0] = '\0';
  Option = opt_unknown;
  while (EOF != (argch = getopt (argc, argv, "u:lerx:")))
    {
      switch (argch)
	{
	case 'x':
	  if (!set_debug_flags (optarg))
	    usage ("bad debug option");
	  break;
	case 'u':
	  if (getuid () != ROOT_UID)
	    {
	      fprintf (stderr, "must be privileged to use -u\n");
	      exit (ERROR_EXIT);
	    }
	  if (!(pw = getpwnam (optarg)))
	    {
	      fprintf (stderr, "%s:  user `%s' unknown\n",
		       ProgramName, optarg);
	      exit (ERROR_EXIT);
	    }
	  (void) strncpy (User, optarg, MAX_UNAME - 1);
	  break;
	case 'l':
	  if (Option != opt_unknown)
	    usage ("only one operation permitted");
	  Option = opt_list;
	  break;
	case 'r':
	  if (Option != opt_unknown)
	    usage ("only one operation permitted");
	  Option = opt_delete;
	  break;
	case 'e':
	  if (Option != opt_unknown)
	    usage ("only one operation permitted");
	  Option = opt_edit;
	  break;
	default:
	  usage ("unrecognized option");
	}
    }

  endpwent ();

  if (Option != opt_unknown)
    {
      if (argv[optind] != NULL)
	{
	  usage ("no arguments permitted after this option");
	}
    }
  else
    {
      if (argv[optind] != NULL)
	{
	  Option = opt_replace;
	  (void) strncpy (Filename, argv[optind], sizeof (Filename) - 1);
	  Filename[sizeof (Filename) - 1] = '\0';
	}
      else
	{
	  usage ("file name must be specified for replace");
	}
    }

  if (Option == opt_replace)
    {
      /* we have to open the file here because we're going to
       * chdir(2) into /var/cron before we get around to
       * reading the file.
       */
      if (!strcmp (Filename, "-"))
	{
	  NewCrontab = stdin;
	}
      else
	{
	  /* relinquish the setuid status of the binary during
	   * the open, lest nonroot users read files they should
	   * not be able to read.  we can't use access() here
	   * since there's a race condition.  thanks go out to
	   * Arnt Gulbrandsen <*****@*****.**> for spotting
	   * the race.
	   */

	  if (swap_uids () < OK)
	    {
	      perror ("swapping uids");
	      exit (ERROR_EXIT);
	    }
	  if (!(NewCrontab = fopen (Filename, "r")))
	    {
	      perror (Filename);
	      exit (ERROR_EXIT);
	    }
	  if (swap_uids () < OK)
	    {
	      perror ("swapping uids back");
	      exit (ERROR_EXIT);
	    }
	}
    }

  Debug (DMISC, ("user=%s, file=%s, option=%s\n",
		 User, Filename, Options[(int) Option]));
}
コード例 #22
0
int main(int argc, char **argv)
{
		// Set up the dprintf stuff...
	dprintf_set_tool_debug("test_check_events", 0);
	set_debug_flags(NULL, D_ALWAYS);

	bool			result = true;

	Status tmpStatus = CheckArgs(argc, argv);
	if ( tmpStatus == STATUS_CANCEL ) {
		return 0;
	} else if ( tmpStatus == STATUS_ERROR ) {
		return 1;
	}

	//-------------------------------------------------------------------------

	printf("\n### Testing various error conditions (multiple "
			"submits, etc.)\n\n");

	CheckEvents		ce1;
	MyString		errorMsg;

		// Test a submit event.
	SubmitEvent		se1;
	se1.cluster = 1234;
	se1.proc = 0;
	se1.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &se1, CheckEvents::EVENT_OKAY, result);

		// Re-do the same submit event -- this should generate an error.
	CheckThisEvent(__LINE__, ce1, &se1, CheckEvents::EVENT_ERROR, result);

		// Test a submit event for a new job.
	SubmitEvent		se2;
	se2.cluster = 1234;
	se2.proc = 1;
	se2.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &se2, CheckEvents::EVENT_OKAY, result);

		// Test a terminate event.  This should no longer fail because
		// of better support for "write at least once" semantics.
	JobTerminatedEvent	te1;
	te1.cluster = 1234;
	te1.proc = 0;
	te1.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &te1, CheckEvents::EVENT_OKAY, result);

		// Test a job aborted event.
	JobAbortedEvent	ae2;
	ae2.cluster = 1234;
	ae2.proc = 1;
	ae2.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &ae2, CheckEvents::EVENT_OKAY, result);

		// Test an execute event.  This should fail because we already
		// got an aborted event for this job.
	ExecuteEvent exec;
	exec.cluster = 1234;
	exec.proc = 1;
	exec.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &exec, CheckEvents::EVENT_ERROR, result);

		// Test an execute event.  This should fail because we haven't
		// gotten a submit event for this job.
	exec.cluster = 1234;
	exec.proc = 5;
	exec.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &exec, CheckEvents::EVENT_ERROR, result);

		// Test a terminate event.  This should fail because we already
		// got an aborted event for this job.
	JobTerminatedEvent	te2;
	te2.cluster = 1234;
	te2.proc = 1;
	te2.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &te2, CheckEvents::EVENT_ERROR, result);

		// Test a job aborted event.  This should fail because we
		// don't have a submit event for this job yet.
	JobAbortedEvent	ae3;
	ae3.cluster = 1236;
	ae3.proc = 0;
	ae3.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &ae3, CheckEvents::EVENT_ERROR, result);

		// Test a submit event for the job that just aborted.  This
		// should fail because we got the abort before the submit.
	SubmitEvent		se3;
	se3.cluster = 1236;
	se3.proc = 0;
	se3.subproc = 0;

	CheckThisEvent(__LINE__, ce1, &se3, CheckEvents::EVENT_ERROR, result);

	printf("\nTesting CheckAllJobs()... ");
	CheckEvents::check_event_result_t tmpResult = ce1.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing good events\n\n");

		// Make a new CheckEvents object where we only insert "correct"
		// events...
	CheckEvents		ce2;
	CheckThisEvent(__LINE__, ce2, &se1, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce2, &se2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce2, &te1, CheckEvents::EVENT_OKAY, result);

		// This should fail because the second job doesn't have a terminate
		// or abort event.
	printf("Testing CheckAllJobs()... ");
	tmpResult = ce2.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	ExecutableErrorEvent	ee2;
	ee2.cluster = 1234;
	ee2.proc = 1;
	ee2.subproc = 0;

	CheckThisEvent(__LINE__, ce2, &ee2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce2, &ae2, CheckEvents::EVENT_OKAY, result);

	PostScriptTerminatedEvent pt1;
		// Note: special "no submit" ID.
	pt1.cluster = -1;
	pt1.proc = 0;
	pt1.subproc = 0;

	CheckThisEvent(__LINE__, ce2, &pt1, CheckEvents::EVENT_OKAY, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce2.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_OKAY, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing \"extra\" abort events\n\n");

		// Make a new CheckEvents object that allows extra abort events
		// (apparently Condor sometimes generates a terminate and an abort
		// event).
	CheckEvents		ce3(CheckEvents::ALLOW_TERM_ABORT);

	SubmitEvent		se4;
	se4.cluster = 9876;
	se4.proc = 5;
	se4.subproc = 0;

	CheckThisEvent(__LINE__, ce3, &se4, CheckEvents::EVENT_OKAY, result);

	ExecuteEvent exec2;
	exec2.cluster = 9876;
	exec2.proc = 5;
	exec2.subproc = 0;

	CheckThisEvent(__LINE__, ce3, &exec2, CheckEvents::EVENT_OKAY, result);

	JobTerminatedEvent	te3;
	te3.cluster = 9876;
	te3.proc = 5;
	te3.subproc = 0;

	CheckThisEvent(__LINE__, ce3, &te3, CheckEvents::EVENT_OKAY, result);

	JobAbortedEvent	ae4;
	ae4.cluster = 9876;
	ae4.proc = 5;
	ae4.subproc = 0;

	CheckThisEvent(__LINE__, ce3, &ae4, CheckEvents::EVENT_BAD_EVENT, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce3.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing that we catch \"extra\" abort events if we don't "
			"explicitly allow them\n\n");

	CheckEvents		ce4;

	CheckThisEvent(__LINE__, ce4, &se4, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce4, &exec2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce4, &te3, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce4, &ae4, CheckEvents::EVENT_ERROR, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce4.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing multiple runs\n\n");
	CheckEvents		ce5(CheckEvents::ALLOW_RUN_AFTER_TERM);

	CheckThisEvent(__LINE__, ce5, &se4, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce5, &exec2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce5, &te3, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce5, &exec2, CheckEvents::EVENT_BAD_EVENT, result);

	CheckThisEvent(__LINE__, ce5, &te3, CheckEvents::EVENT_BAD_EVENT, result);

	printf("\nTesting CheckAllJobs()... ");
		// Note that here we're no longer explicitly allowing "run after
		// terminate", but this check doesn't fail because we don't know
		// whether any of the terminates came before the executes.
	ce5.SetAllowEvents(CheckEvents::ALLOW_DOUBLE_TERMINATE);
	tmpResult = ce5.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing that we catch multiple runs if we don't "
			"explicitly allow them\n\n");

	CheckEvents		ce6;

	CheckThisEvent(__LINE__, ce6, &se4, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce6, &exec2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce6, &te3, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce6, &exec2, CheckEvents::EVENT_ERROR, result);

	CheckThisEvent(__LINE__, ce6, &te3, CheckEvents::EVENT_ERROR, result);

	CheckThisEvent(__LINE__, ce6, &pt1, CheckEvents::EVENT_OKAY, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce6.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing garbage\n\n");

	CheckEvents		ce7(CheckEvents::ALLOW_GARBAGE);

	SubmitEvent		se5;
	se4.cluster = 1000;
	se4.proc = 0;
	se4.subproc = 0;

	CheckThisEvent(__LINE__, ce7, &se5, CheckEvents::EVENT_OKAY, result);

	ExecuteEvent exec3;
	exec3.cluster = 2000; // Note different from submit event!
	exec3.proc = 0;
	exec3.subproc = 0;

	CheckThisEvent(__LINE__, ce7, &exec3, CheckEvents::EVENT_WARNING, result);

	JobTerminatedEvent	te4;
	te4.cluster = 3000;
	te4.proc = 0;
	te4.subproc = 0;

	CheckThisEvent(__LINE__, ce7, &te4, CheckEvents::EVENT_WARNING, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce7.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	CheckThisEvent(__LINE__, ce7, &te4, CheckEvents::EVENT_ERROR, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce7.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing almost all bad events\n\n");

	CheckEvents		ce8(CheckEvents::ALLOW_ALMOST_ALL);

	ExecuteEvent exec8;
	exec8.cluster = 1234;
	exec8.proc = 0;
	exec8.subproc = 0;

	CheckThisEvent(__LINE__, ce8, &exec8, CheckEvents::EVENT_WARNING, result);

	CheckThisEvent(__LINE__, ce8, &se1, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce8, &te1, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce8, &se1, CheckEvents::EVENT_BAD_EVENT, result);

		// ALLOW_ALMOST_ALL should *not* allow execute after terminate.
	CheckThisEvent(__LINE__, ce8, &exec8, CheckEvents::EVENT_ERROR, result);

	CheckThisEvent(__LINE__, ce8, &te1, CheckEvents::EVENT_BAD_EVENT, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce8.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing execute before submit\n\n");

	CheckEvents		ce9(CheckEvents::ALLOW_EXEC_BEFORE_SUBMIT);

	ExecuteEvent exec9;
	exec9.cluster = 1234;
	exec9.proc = 0;
	exec9.subproc = 0;
	CheckThisEvent(__LINE__, ce9, &exec9, CheckEvents::EVENT_WARNING, result);

	CheckThisEvent(__LINE__, ce9, &se1, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce9, &te1, CheckEvents::EVENT_OKAY, result);

		// This should return OKAY because at this point we don't
		// remember that the execute came before the submit.
	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce9.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_OKAY, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing double-terminate\n\n");

	CheckEvents		ce10(CheckEvents::ALLOW_DOUBLE_TERMINATE);

	CheckThisEvent(__LINE__, ce10, &se1, CheckEvents::EVENT_OKAY, result);

	ExecuteEvent exec10;
	exec10.cluster = 1234;
	exec10.proc = 0;
	exec10.subproc = 0;
	CheckThisEvent(__LINE__, ce10, &exec10, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce10, &te1, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce10, &te1, CheckEvents::EVENT_BAD_EVENT, result);

	PostScriptTerminatedEvent pt10;
	pt10.cluster = 1234;
	pt10.proc = 0;
	pt10.subproc = 0;
	CheckThisEvent(__LINE__, ce10, &pt10, CheckEvents::EVENT_OKAY, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce10.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	CheckThisEvent(__LINE__, ce10, &se2, CheckEvents::EVENT_OKAY, result);

	exec10.proc = 1;
	CheckThisEvent(__LINE__, ce10, &exec10, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce10, &te2, CheckEvents::EVENT_OKAY, result);

		// Terminate then execute should still be an error.
	CheckThisEvent(__LINE__, ce10, &exec10, CheckEvents::EVENT_ERROR, result);

	CheckThisEvent(__LINE__, ce10, &te2, CheckEvents::EVENT_BAD_EVENT, result);

		// We get bad event here instead of error because we don't
		// "remember" that an execute event came after a terminated event.
	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce10.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing running POST scripts after submit failures\n\n");

	CheckEvents		ce11;

	PostScriptTerminatedEvent pt2;
		// ID of POST script terminated event is -1.0.0 if all submit
		// attempts of the node job failed.
	pt2.cluster = -1;
	pt2.proc = 0;
	pt2.subproc = 0;

	CheckThisEvent(__LINE__, ce11, &pt2, CheckEvents::EVENT_OKAY, result);

		// This is okay because we specifically allow duplicates with the
		// special "submit attempts failed" ID.
	CheckThisEvent(__LINE__, ce11, &pt2, CheckEvents::EVENT_OKAY, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce11.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_OKAY, tmpResult, errorMsg,
			result);

		// Make sure we flag multiple post script terminates for a *real*
		// job as errors...
	SubmitEvent		se11;
	se11.cluster = 1234;
	se11.proc = 0;
	se11.subproc = 0;

	CheckThisEvent(__LINE__, ce11, &se11, CheckEvents::EVENT_OKAY, result);

	JobTerminatedEvent	te11;
	te11.cluster = 1234;
	te11.proc = 0;
	te11.subproc = 0;

	CheckThisEvent(__LINE__, ce11, &te11, CheckEvents::EVENT_OKAY, result);

	pt2.cluster = 1234;
	pt2.proc = 0;
	pt2.subproc = 0;

	CheckThisEvent(__LINE__, ce11, &pt2, CheckEvents::EVENT_OKAY, result);

	CheckThisEvent(__LINE__, ce11, &pt2, CheckEvents::EVENT_ERROR, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce11.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_ERROR, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing terminate after post script terminate\n\n");

	CheckEvents		ce12;

	SubmitEvent		se12;
	se12.cluster = 1234;
	se12.proc = 1;
	se12.subproc = 0;
	CheckThisEvent(__LINE__, ce12, &se12, CheckEvents::EVENT_OKAY, result);

	ExecuteEvent exec12;
	exec12.cluster = 1234;
	exec12.proc = 1;
	exec12.subproc = 0;
	CheckThisEvent(__LINE__, ce12, &exec12, CheckEvents::EVENT_OKAY, result);

	PostScriptTerminatedEvent pt12;
	pt12.cluster = 1234;
	pt12.proc = 1;
	pt12.subproc = 0;
	CheckThisEvent(__LINE__, ce12, &pt12, CheckEvents::EVENT_ERROR, result);

	JobTerminatedEvent	te12;
	te12.cluster = 1234;
	te12.proc = 1;
	te12.subproc = 0;
	CheckThisEvent(__LINE__, ce12, &te12, CheckEvents::EVENT_ERROR, result);

	//-------------------------------------------------------------------------

	printf("\n### Testing parallel universe\n\n");

	CheckEvents		ce13;

	SubmitEvent		se13;
	se13.cluster = 101176;
	se13.proc = 0;
	se13.subproc = 0;
	CheckThisEvent(__LINE__, ce13, &se13, CheckEvents::EVENT_OKAY, result);

	NodeExecuteEvent	ne13;
	ne13.cluster = 101176;
	ne13.proc = 0;
	ne13.subproc = 0;
	CheckThisEvent(__LINE__, ce13, &ne13, CheckEvents::EVENT_OKAY, result);

	ne13.subproc = 1;
	CheckThisEvent(__LINE__, ce13, &ne13, CheckEvents::EVENT_OKAY, result);

	ExecuteEvent	exec13;
	exec13.cluster = 101176;
	exec13.proc = 0;
	exec13.subproc = 0;
	CheckThisEvent(__LINE__, ce13, &exec13, CheckEvents::EVENT_OKAY, result);

	NodeExecuteEvent	nt13;
	nt13.cluster = 101176;
	nt13.proc = 0;
	nt13.subproc = 0;
	CheckThisEvent(__LINE__, ce13, &nt13, CheckEvents::EVENT_OKAY, result);

	nt13.subproc = 1;
	CheckThisEvent(__LINE__, ce13, &nt13, CheckEvents::EVENT_OKAY, result);

	JobTerminatedEvent	te13;
	te13.cluster = 101176;
	te13.proc = 0;
	te13.subproc = 0;
	CheckThisEvent(__LINE__, ce13, &te13, CheckEvents::EVENT_OKAY, result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce13.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_OKAY, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing duplicate events\n\n");

	CheckEvents		ce14(CheckEvents::ALLOW_DUPLICATE_EVENTS);

	SubmitEvent		se14;
	se14.cluster = 123;
	se14.proc = 0;
	se14.subproc = 0;
	CheckThisEvent(__LINE__, ce14, &se14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &se14, CheckEvents::EVENT_BAD_EVENT,
			result);

	ExecuteEvent exec14;
	exec14.cluster = 123;
	exec14.proc = 0;
	exec14.subproc = 0;
	CheckThisEvent(__LINE__, ce14, &exec14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &exec14, CheckEvents::EVENT_OKAY, result);

	JobTerminatedEvent	te14;
	te14.cluster = 123;
	te14.proc = 0;
	te14.subproc = 0;
	CheckThisEvent(__LINE__, ce14, &te14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &te14, CheckEvents::EVENT_BAD_EVENT,
			result);

	PostScriptTerminatedEvent pt14;
	pt14.cluster = 123;
	pt14.proc = 0;
	pt14.subproc = 0;
	CheckThisEvent(__LINE__, ce14, &pt14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &pt14, CheckEvents::EVENT_BAD_EVENT,
			result);

	CheckThisEvent(__LINE__, ce14, &te14, CheckEvents::EVENT_BAD_EVENT,
			result);

	//~~~~~~~~~~~~~~~~~~~~~

	se14.cluster = 124;
	CheckThisEvent(__LINE__, ce14, &se14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &se14, CheckEvents::EVENT_BAD_EVENT,
			result);

	exec14.cluster = 124;
	CheckThisEvent(__LINE__, ce14, &exec14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &exec14, CheckEvents::EVENT_OKAY, result);

	JobAbortedEvent	ae14;
	ae14.cluster = 124;
	ae14.proc = 0;
	ae14.subproc = 0;
	CheckThisEvent(__LINE__, ce14, &ae14, CheckEvents::EVENT_OKAY, result);
	CheckThisEvent(__LINE__, ce14, &ae14, CheckEvents::EVENT_BAD_EVENT,
			result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce14.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_BAD_EVENT, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	printf("\n### Testing allowing terminated before submit\n\n");

	CheckEvents		ce15(CheckEvents::ALLOW_EXEC_BEFORE_SUBMIT);

	ExecuteEvent exec15;
	exec15.cluster = 123;
	exec15.proc = 0;
	exec15.subproc = 0;
	CheckThisEvent(__LINE__, ce15, &exec15, CheckEvents::EVENT_WARNING,
			result);

	JobTerminatedEvent	te15;
	te15.cluster = 123;
	te15.proc = 0;
	te15.subproc = 0;
	CheckThisEvent(__LINE__, ce15, &te15, CheckEvents::EVENT_WARNING,
			result);

	SubmitEvent		se15;
	se15.cluster = 123;
	se15.proc = 0;
	se15.subproc = 0;
	CheckThisEvent(__LINE__, ce15, &se15, CheckEvents::EVENT_BAD_EVENT,
			result);

	printf("\nTesting CheckAllJobs()... ");
	tmpResult = ce15.CheckAllJobs(errorMsg);
	CheckResult(__LINE__, CheckEvents::EVENT_OKAY, tmpResult, errorMsg,
			result);

	//-------------------------------------------------------------------------

	if ( result ) {
		printf("\nTest SUCCCEEDED\n");
		return 0;
	} else {
		printf("\nTest FAILED!!!!!!!!!!!!!!!!!!!!!!!!!\n");
		return 1;
	}
}