Exemplo n.º 1
0
void
test_compile(void)
{
	struct sym_test *st;
	struct compile_env *cenv;
	test_t t;
	int need;

	for (st = next_sym_test(NULL); st; st = next_sym_test(st)) {
		if ((sym != NULL) && strcmp(sym, sym_test_name(st))) {
			continue;
		}
		/* XXX: we really want a sym_test_desc() */
		for (cenv = sym_test_env(st, NULL, &need);
		    cenv != NULL;
		    cenv = sym_test_env(st, cenv, &need)) {
			t = test_start("%s : %c%s", sym_test_name(st),
			    need ? '+' : '-', env_name(cenv));
			if (do_compile(t, st, cenv, need) == 0) {
				test_passed(t);
			}
		}
	}

	if (full_count > 0) {
		test_summary();
	}
}
Exemplo n.º 2
0
END_TEST

#if 0
START_TEST(SEGINFO0300)
{
    const envitem_t* envitem;

    envitem = iguana_getenv("MAIN/STACK");
    fail_if(envitem == NULL,
            "Couldn't find stack entry.");

    envitem = iguana_getenv("main/stack");
    fail_if(envitem == NULL,
            "Couldn't find stack entry (lowercase).");

    envitem = iguana_getenv("does_not_exist");
    fail_if(envitem != NULL,
            "Search for non-existent item succeeded.");

    envitem = env_get_next(NULL);
    fail_if(envitem == NULL,
            "Failed to get the first item.");
    if (envitem != NULL) {
        /*
         * Check the name of the first item.  This test is dependent
         * on the current implementation and may fail if something in
         * elfweaver changes.
         */
        fail_unless(strcmp(env_name(envitem), "MAIN") == 0,
                    "Unexpected name for first item.");

        /*
         * Run through the list.
         * Because the contents of the object environment are unknown
         * it is not possible to test things here.  However, if the
         * test hangs then something is wrong!
         */
        while ((envitem = env_get_next(envitem)) != NULL) {
        }
    }
}
Exemplo n.º 3
0
 //---------------------------------------------------------------------------
 const char* Evaluator::getEnviron(const char* name)  {
   Struct* s = reinterpret_cast<Struct*>(p);
   string item_name = name;
   //std::cout << " ++++++++++++++++++++++++++++ Try to resolve env:" << name << std::endl;
   dic_type::iterator iter = (s->theDictionary).find(item_name);
   if (iter != (s->theDictionary).end()) {
     s->theStatus = EVAL::OK;
     return iter->second.expression.c_str();
   }
   if ( ::strlen(item_name.c_str()) > 3 )  {
     // Need to remove braces from ${xxxx} for call to getenv()
     string env_name(name+2,::strlen(name)-3);
     const char* env_str = ::getenv(env_name.c_str());
     if ( 0 != env_str )    {
       s->theStatus = EVAL::OK;
       return env_str;
     }
   }
   s->theStatus = EVAL::ERROR_UNKNOWN_VARIABLE;
   return 0;
 }
Exemplo n.º 4
0
static DdManager *get_manager()
{
  int i, l;
  int lb, ub;
  int tmp, next_var;

  if (manager == NULL) {
    l = env_size();
    next_var = 0;
    for (i = l; i; --i) {
      env_name(i, &lb, &ub);
      cudd_var_bits[i] = next_var;
      tmp = ub-lb;
      while (tmp) {
        tmp >>= 1;
        next_var += 2;
      }
    }
    cudd_var_bits[0] = next_var;
    
    manager = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
  }
Exemplo n.º 5
0
int
do_compile(test_t t, struct sym_test *st, struct compile_env *cenv, int need)
{
	char *cmd;
	FILE *logf;
	FILE *dotc;
	const char *prog, *cflags, *lang;

	full_count++;

	if ((dotc = fopen(cfile, "w+")) == NULL) {
		test_failed(t, "fopen(%s): %s", cfile, strerror(errno));
		return (-1);
	}
	prog = sym_test_prog(st);
	if (fwrite(prog, 1, strlen(prog), dotc) < strlen(prog)) {
		test_failed(t, "fwrite: %s", strerror(errno));
		(void) fclose(dotc);
		return (-1);
	}
	if (fclose(dotc) < 0) {
		test_failed(t, "fclose: %s", strerror(errno));
		return (-1);
	}

	(void) unlink(ofile);

	if (strcmp(env_lang(cenv), "c99") == 0) {
		lang = "c99";
		cflags = c99flags;
	} else if (strcmp(env_lang(cenv), "c11") == 0) {
		lang = "c11";
		cflags = c11flags;
	} else {
		lang = "c89";
		cflags = c89flags;
	}

	if (cflags == NULL) {
		test_failed(t, "compiler %s does not support %s", compiler,
		    lang);
		return (-1);
	}

	myasprintf(&cmd, "%s %s %s -c %s -o %s >>%s 2>&1",
	    compiler, cflags, env_defs(cenv), cfile, ofile, lfile);

	if (extra_debug) {
		test_debugf(t, "command: %s", cmd);
	}

	if ((logf = fopen(lfile, "w+")) == NULL) {
		test_failed(t, "fopen: %s", strerror(errno));
		return (-1);
	}
	(void) fprintf(logf, "===================\n");
	(void) fprintf(logf, "PROGRAM:\n%s\n", sym_test_prog(st));
	(void) fprintf(logf, "COMMAND: %s\n", cmd);
	(void) fprintf(logf, "EXPECT: %s\n", need ? "OK" : "FAIL");
	(void) fclose(logf);

	switch (system(cmd)) {
	case -1:
		test_failed(t, "error compiling in %s: %s", env_name(cenv),
		    strerror(errno));
		return (-1);
	case 0:
		if (!need) {
			fail_count++;
			show_file(t, lfile);
			test_failed(t, "symbol visible in %s", env_name(cenv));
			return (-1);
		}
		break;
	default:
		if (need) {
			fail_count++;
			show_file(t, lfile);
			test_failed(t, "error compiling in %s", env_name(cenv));
			return (-1);
		}
		break;
	}
	good_count++;
	return (0);
}