예제 #1
0
static void
update_shared_paths (CajaShares *shares)
{
  /* clean up the paths */
  g_hash_table_remove_all (shares->paths);

  add_paths (shares->paths, oobs_smb_config_get_shares (OOBS_SMB_CONFIG (shares->smb_config)));
  add_paths (shares->paths, oobs_nfs_config_get_shares (OOBS_NFS_CONFIG (shares->nfs_config)));
}
예제 #2
0
파일: tst_test.c 프로젝트: sathnaga/ltp
static void testrun(void)
{
	unsigned int i = 0;
	unsigned long long stop_time = 0;
	int cont = 1;

	add_paths();
	do_test_setup();

	if (duration > 0)
		stop_time = get_time_ms() + (unsigned long long)(duration * 1000);

	for (;;) {
		cont = 0;

		if (i < (unsigned int)iterations) {
			i++;
			cont = 1;
		}

		if (stop_time && get_time_ms() < stop_time)
			cont = 1;

		if (!cont)
			break;

		run_tests();
		heartbeat();
	}

	do_test_cleanup();
	exit(0);
}
예제 #3
0
파일: jcc.cpp 프로젝트: ahua/java
_DLL_EXPORT PyObject *initVM(PyObject *self, PyObject *args, PyObject *kwds)
{
    static char *kwnames[] = {
        "classpath", "initialheap", "maxheap", "maxstack",
        "vmargs", NULL
    };
    char *classpath = NULL;
    char *initialheap = NULL, *maxheap = NULL, *maxstack = NULL;
    PyObject *vmargs = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzO", kwnames,
                                     &classpath,
                                     &initialheap, &maxheap, &maxstack,
                                     &vmargs))
        return NULL;

    if (env->vm)
    {
        PyObject *module_cp = NULL;

        if (initialheap || maxheap || maxstack || vmargs)
        {
            PyErr_SetString(PyExc_ValueError,
                            "JVM is already running, options are ineffective");
            return NULL;
        }

        if (classpath == NULL && self != NULL)
        {
            module_cp = PyObject_GetAttrString(self, "CLASSPATH");
            if (module_cp != NULL)
                classpath = PyString_AsString(module_cp);
        }

        if (classpath && classpath[0])
            env->setClassPath(classpath);

        Py_XDECREF(module_cp);

        return getVMEnv(self);
    }
    else
    {
        JavaVMInitArgs vm_args;
        JavaVMOption vm_options[32];
        JNIEnv *vm_env;
        JavaVM *vm;
        unsigned int nOptions = 0;
        PyObject *module_cp = NULL;

        vm_args.version = JNI_VERSION_1_4;
        JNI_GetDefaultJavaVMInitArgs(&vm_args);

        if (classpath == NULL && self != NULL)
        {
            module_cp = PyObject_GetAttrString(self, "CLASSPATH");
            if (module_cp != NULL)
                classpath = PyString_AsString(module_cp);
        }

#ifdef _jcc_lib
        PyObject *jcc = PyImport_ImportModule("jcc");
        PyObject *cp = PyObject_GetAttrString(jcc, "CLASSPATH");

        if (classpath)
            add_paths("-Djava.class.path=", PyString_AsString(cp), classpath,
                      &vm_options[nOptions++]);
        else
            add_option("-Djava.class.path=", PyString_AsString(cp),
                       &vm_options[nOptions++]);
            
        Py_DECREF(cp);
        Py_DECREF(jcc);
#else
        if (classpath)
            add_option("-Djava.class.path=", classpath,
                       &vm_options[nOptions++]);
#endif

        Py_XDECREF(module_cp);

        if (initialheap)
            add_option("-Xms", initialheap, &vm_options[nOptions++]);
        if (maxheap)
            add_option("-Xmx", maxheap, &vm_options[nOptions++]);
        if (maxstack)
            add_option("-Xss", maxstack, &vm_options[nOptions++]);

        if (vmargs != NULL && PyString_Check(vmargs))
        {
#ifdef _MSC_VER
            char *buf = _strdup(PyString_AS_STRING(vmargs));
#else
            char *buf = strdup(PyString_AS_STRING(vmargs));
#endif
            char *sep = ",";
            char *option;

            for (option = strtok(buf, sep); option != NULL;
                 option = strtok(NULL, sep)) {
                if (nOptions < sizeof(vm_options) / sizeof(JavaVMOption))
                    add_option("", option, &vm_options[nOptions++]);
                else
                {
                    free(buf);
                    for (unsigned int i = 0; i < nOptions; i++)
                        delete vm_options[i].optionString;
                    PyErr_Format(PyExc_ValueError,
                                 "Too many options (> %d)", nOptions);
                    return NULL;
                }
            }
            free(buf);
        }
        else if (vmargs != NULL && PySequence_Check(vmargs))
        {
            PyObject *fast =
                PySequence_Fast(vmargs, "error converting vmargs to a tuple");

            if (fast == NULL)
                return NULL;

            for (int i = 0; i < PySequence_Fast_GET_SIZE(fast); ++i) {
                PyObject *arg = PySequence_Fast_GET_ITEM(fast, i);

                if (PyString_Check(arg))
                {
                    char *option = PyString_AS_STRING(arg);

                    if (nOptions < sizeof(vm_options) / sizeof(JavaVMOption))
                        add_option("", option, &vm_options[nOptions++]);
                    else
                    {
                        for (unsigned int j = 0; j < nOptions; j++)
                            delete vm_options[j].optionString;
                        PyErr_Format(PyExc_ValueError,
                                     "Too many options (> %d)", nOptions);
                        Py_DECREF(fast);
                        return NULL;
                    }
                }
                else
                {
                    for (unsigned int j = 0; j < nOptions; j++)
                        delete vm_options[j].optionString;
                    PyErr_Format(PyExc_TypeError,
                                 "vmargs arg %d is not a string", i);
                    Py_DECREF(fast);
                    return NULL;
                }
            }

            Py_DECREF(fast);
        }
        else if (vmargs != NULL)
        {
            PyErr_SetString(PyExc_TypeError,
                            "vmargs is not a string or sequence");
            return NULL;
        }

        //vm_options[nOptions++].optionString = "-verbose:gc";
        //vm_options[nOptions++].optionString = "-Xcheck:jni";

        vm_args.nOptions = nOptions;
        vm_args.ignoreUnrecognized = JNI_FALSE;
        vm_args.options = vm_options;

        if (JNI_CreateJavaVM(&vm, (void **) &vm_env, &vm_args) < 0)
        {
            for (unsigned int i = 0; i < nOptions; i++)
                delete vm_options[i].optionString;

            PyErr_Format(PyExc_ValueError,
                         "An error occurred while creating Java VM");
            return NULL;
        }

        env->set_vm(vm, vm_env);

        for (unsigned int i = 0; i < nOptions; i++)
            delete vm_options[i].optionString;

        t_jccenv *jccenv = (t_jccenv *) PY_TYPE(JCCEnv).tp_alloc(&PY_TYPE(JCCEnv), 0);
        jccenv->env = env;

#ifdef _jcc_lib
        registerNatives(vm_env);
#endif

        return (PyObject *) jccenv;
    }
}
예제 #4
0
void drive_frontend(){

	//printf("drive_frontend\n");

	set_option("follow_path", "true");
	set_option("single_step", "true");

	set<PathAndConds> frontier;

	load_heuristics();

	int n = 0;
	do {
		PathAndConds first;
		if(frontier.size()){

			bool pick_random = cmd_option_bool("random_branching");
			//bool pick_random = true;
			if(pick_random){
				int pick = rand() % frontier.size() - 1;
				set<PathAndConds>::iterator it = frontier.begin(); it++;
				while(pick > 0){
					it++; pick--;
				}
				first = *(it);
				frontier.erase(it);
			} else {
				first = *(frontier.begin());
				frontier.erase(frontier.begin());
			}
		}

		set_option("path", first.path);
		set_option("file_initializations", first.file_initializations);

		options_to_file();

		db_command("delete from frontend;");
		db_command("delete from results;");
		db_command("delete from last_bb;");
		db_command("delete from variables;");

		// Run resulting file
		stringstream cmd;
		cmd << "./" << cmd_option_str("output_file");
		systm(cmd.str().c_str());

		add_paths(frontier);

		if(n++ == cmd_option_int("max_depth"))
			exit(0);

		if(cmd_option_bool("show_frontier")){
			printf("last_bb %s\n", get_last_bb().c_str() ); // last one executed.
			// frontier contains the constraints to get to last_bb + the last constraint
			
			if(get_last_bb() == cmd_option_str("target_node")){
				printf("Node hitted\n");
				//exit(0);
				break;
			}

			print_frontier(frontier);

			if(cmd_option_bool("stop_in_frontier"))
				getchar();
		}


	} while(frontier.size());

}