Esempio n. 1
0
int main(void) {
	test_register(&tModSubscriber);
	test_register(&tModRect);
	test_start();
	/* flush stdout because cout will be closed before stdout is flushed by exit(). thus, that flush
	 * will fail because the file has already been closed. */
	fflush(stdout);
	return EXIT_SUCCESS;
}
Esempio n. 2
0
int main(int /*@unused@*/ argc, char /*@unused@*/ **arv)
{
	const char *test_config_file = TESTDIR "naemon.cfg";
	plan_tests(489);
	init_event_queue();

	config_file_dir = nspath_absolute_dirname(test_config_file, NULL);
	assert(OK == read_main_config_file(test_config_file));
	assert(OK == read_all_object_data(test_config_file));
	assert(OK == initialize_downtime_data());
	assert(OK == initialize_retention_data());
	test_register();
	test_parsing();
	test_core_commands();
	return exit_status();
}
Esempio n. 3
0
static expression_t *ack_get_operand(asm86_t * a, int *pn, int deref)
/* Get something like: (memory), offset(base)(index*scale), or simpler. */
{
	expression_t *e, *offset, *base, *index;
	token_t *t;
	int c;

	/* Is it (memory)? */
	if (get_token(*pn)->symbol == '('
		&& ((t= get_token(*pn + 1))->type != T_WORD
			|| !test_register(t->name, a))
	) {
		/* A memory dereference. */
		(*pn)++;
		if ((offset= ack_get_C_expression(pn, a)) == nil) return nil;
		if (get_token(*pn)->symbol != ')') {
			parse_err(1, t, "operand syntax error\n");
			del_expr(offset);
			return nil;
		}
		(*pn)++;
		e= new_expr();
		e->operator= '(';
		e->middle= offset;

		/* 
		 * the default size is WORD however int on i386 is 32bit and the
		 * assembler cannot figure it out on its own. We are also taking
		 * our chance here though
		 */
		if (use32() && a->optype == WORD)
			a->optype = OWORD;

		return e;
	}

	/* #constant? */
	if (dialect == NCC && deref
			&& ((c= get_token(*pn)->symbol) == '#' || c == '*')) {
		/* NCC: mov ax,#constant  ->  ACK: mov ax,constant */
		(*pn)++;
		return ack_get_C_expression(pn, a);
	}

	/* @address? */
	if (dialect == NCC && get_token(*pn)->symbol == '@') {
		/* NCC: jmp @address  ->  ACK: jmp (address) */
		(*pn)++;
		if ((offset= ack_get_operand(a, pn, deref)) == nil) return nil;
		e= new_expr();
		e->operator= '(';
		e->middle= offset;
		return e;
	}

	/* Offset? */
	if (get_token(*pn)->symbol != '(') {
		/* There is an offset. */
		if ((offset= ack_get_C_expression(pn, a)) == nil) return nil;
	} else {
		/* No offset. */
		offset= nil;
	}

	/* (base)? */
	if (get_token(*pn)->symbol == '('
		&& (t= get_token(*pn + 1))->type == T_WORD
		&& test_register(t->name, a)
		&& get_token(*pn + 2)->symbol == ')'
	) {
		/* A base register expression. */
		base= new_expr();
		base->operator= 'B';
		base->name= copystr(t->name);
		(*pn)+= 3;
	} else {
		/* No base register expression. */
		base= nil;
	}

	/* (index*scale)? */
	if (get_token(*pn)->symbol == '(') {
		/* An index most likely. */
		token_t *m= nil;

		if (!(		/* This must be true: */
			(t= get_token(*pn + 1))->type == T_WORD
			&& test_register(t->name, a)
			&& (get_token(*pn + 2)->symbol == ')' || (
				get_token(*pn + 2)->symbol == '*'
				&& (m= get_token(*pn + 3))->type == T_WORD
				&& strchr("1248", m->name[0]) != nil
				&& m->name[1] == 0
				&& get_token(*pn + 4)->symbol == ')'
			))
		)) {
			/* Alas it isn't */
			parse_err(1, t, "operand syntax error\n");
			del_expr(offset);
			del_expr(base);
			return nil;
		}
		/* Found an index. */
		index= new_expr();
		index->operator= m == nil ? '1' : m->name[0];
		index->name= copystr(t->name);
		(*pn)+= (m == nil ? 3 : 5);
	} else {
		/* No index. */
		index= nil;
	}

	if (dialect == NCC && deref && base == nil && index == nil
		&& !(offset != nil && offset->operator == 'W'
					&& test_register(offset->name, a))
	) {
		/* NCC: mov ax,thing  ->  ACK mov ax,(thing) */
		e= new_expr();
		e->operator= '(';
		e->middle= offset;
		return e;
	}

	if (base == nil && index == nil) {
		/* Return a lone offset as is. */
		e= offset;
	} else {
		e= new_expr();
		e->operator= 'O';
		e->left= offset;
		e->middle= base;
		e->right= index;
	}
	return e;
}
Esempio n. 4
0
int main(void) {
	test_register(&tModHeap);
	test_register(&tModFileio);
	test_register(&tModDir);
	test_register(&tModEnv);
	test_register(&tModFs);
	test_register(&tModMem);
	test_register(&tModSLList);
	test_register(&tModSetjmp);
	test_register(&tModString);
	test_register(&tModMath);
	test_register(&tModQSort);
	test_register(&tModGetOpt);
	test_register(&tModCtype);
	test_register(&tModEscCodes);
	test_start();
	return EXIT_SUCCESS;
}
Esempio n. 5
0
static expression_t *ack_get_C_expression(int *pn, asm86_t * a)
/* Read a "C-like" expression.  Note that we don't worry about precedence,
 * the expression is printed later like it is read.  If the target language
 * does not have all the operators (like ~) then this has to be repaired by
 * changing the source file.  (No problem, you still have one source file
 * to maintain, not two.)
 */
{
	expression_t *e, *a1, *a2;
	token_t *t;

	if ((t= get_token(*pn))->symbol == '[') {
		/* [ expr ]: grouping. */
		(*pn)++;
		if ((a1= ack_get_C_expression(pn, a)) == nil) return nil;
		if (get_token(*pn)->symbol != ']') {
			parse_err(1, t, "missing ]\n");
			del_expr(a1);
			return nil;
		}
		(*pn)++;
		e= new_expr();
		e->operator= '[';
		e->middle= a1;
	} else
	if (t->type == T_WORD || t->type == T_STRING) {
		/* Label, number, or string. */
		e= new_expr();
		e->operator= t->type == T_WORD ? 'W' : 'S';
		e->name= allocate(nil, (t->len+1) * sizeof(e->name[0]));
		memcpy(e->name, t->name, t->len+1);
		test_register(e->name, a);
		e->len= t->len;
		(*pn)++;
	} else
	if (t->symbol == '+' || t->symbol == '-' || t->symbol == '~') {
		/* Unary operator. */
		(*pn)++;
		if ((a1= ack_get_C_expression(pn, a)) == nil) return nil;
		e= new_expr();
		e->operator= t->symbol;
		e->middle= a1;
	} else {
		parse_err(1, t, "expression syntax error\n");
		return nil;
	}

	switch ((t= get_token(*pn))->symbol) {
	case '+':
	case '-':
	case '*':
	case '/':
	case '%':
	case '&':
	case '|':
	case '^':
	case S_LEFTSHIFT:
	case S_RIGHTSHIFT:
		(*pn)++;
		a1= e;
		if ((a2= ack_get_C_expression(pn, a)) == nil) {
			del_expr(a1);
			return nil;
		}
		e= new_expr();
		e->operator= t->symbol;
		e->left= a1;
		e->right= a2;
	}
	return e;
}