Example #1
0
void main(void)
{
	int  status = TC_PASS;

	TC_START("Test sprintf APIs\n");

	PRINT_LINE;

	TC_PRINT("Testing sprintf() with integers ....\n");
	if (sprintf_integer_test() != TC_PASS) {
		status = TC_FAIL;
	}

	TC_PRINT("Testing snprintf() ....\n");
	if (snprintf_test() != TC_PASS) {
		status = TC_FAIL;
	}

	TC_PRINT("Testing vsprintf() ....\n");
	if (vsprintf_test() != TC_PASS) {
		status = TC_FAIL;
	}

	TC_PRINT("Testing vsnprintf() ....\n");
	if (vsnprintf_test() != TC_PASS) {
		status = TC_FAIL;
	}

	TC_PRINT("Testing sprintf() with strings ....\n");
	if (sprintf_stringtest() != TC_PASS) {
		status = TC_FAIL;
	}

	TC_PRINT("Testing sprintf() with misc options ....\n");
	if (sprintf_misc_test() != TC_PASS) {
		status = TC_FAIL;
	}

#ifdef CONFIG_FLOAT
	TC_PRINT("Testing sprintf() with doubles ....\n");
	if (sprintf_double_test() != TC_PASS) {
		status = TC_FAIL;
	}
#endif /* CONFIG_FLOAT */

	TC_END_RESULT(status);
	TC_END_REPORT(status);
}
Example #2
0
int
main(int argc, char *argv[])
{
    if (argc < 2)
	fail("To few arguments for test case");

    {
	char *testcase;
	int save_xres = 0;
	int i;

	send_my_pid();

	testcase = argv[1];
#ifdef THREAD_SAFE
	{
	    int res = ethr_init(NULL);
	    if (res != 0)
		fail("Failed to initialize the ethread library");
	}
#endif

	for (i = 2; i < argc; i++) {
	    if (strcmp(argv[i], "save_expected_result") == 0) {
		save_xres = 1;
		break;
	    }
	}

	if (save_xres) {
	    char filename[100];
	    sprintf(filename,
		    "%s%s_test.h",
		    testcase,
		    sizeof(void *) == 8 ? "_64" : "");
	    printf("Saving expected result to %s\n", filename);
	    outfile = fopen(filename, "w");
	    ASSERT(outfile);
	    fprintf(outfile,
		    "/*\n"
		    " * %%CopyrightBegin%%\n"
		    " * Copyright Ericsson AB 1996-2009. All Rights Reserved.\n"
		    " * \n"
		    " * The contents of this file are subject to the Erlang Public License,\n"
		    " * Version 1.1, (the \"License\"); you may not use this file except in\n"
		    " * compliance with the License. You should have received a copy of the\n"
		    " * Erlang Public License along with this software. If not, it can be\n"
		    " * retrieved online at http://www.erlang.org/.\n"
		    " * \n"
		    " * Software distributed under the License is distributed on an \"AS IS\"\n"
		    " * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See\n"
		    " * the License for the specific language governing rights and limitations\n"
		    " * under the License.\n"
		    " * %%CopyrightEnd%%\n"
		    " */\n"
		    "\n");
	    fprintf(outfile,
		    "/* \n"
		    " * This file has been automatically generated. Do NOT edit it; instead,\n"
		    " * run '%s %s save_expected_result'%s.\n"
		    " */\n"
		    "\n",
		    argv[0],
		    testcase,
		    sizeof(void *) == 8 ? " on a 64-bit machine" : "");
	    fprintf(outfile,
		    "char *%s%s_expected_result[] = {\n",
		    testcase,
		    sizeof(void *) == 8 ? "_64" : "");
	}

	if (strcmp("integer", testcase) == 0)
	    integer_test();
	else if (strcmp("float", testcase) == 0)
	    float_test();
	else if (strcmp("string", testcase) == 0)
	    string_test();
	else if (strcmp("character", testcase) == 0)
	    character_test();
	else if (strcmp("snprintf", testcase) == 0)
	    snprintf_test();
	else if (strcmp("quote", testcase) == 0)
	    quote_test();
	else if (!save_xres)
	    skip("Test case \"%s\" not implemented yet", testcase);

	if (save_xres) {
	    fprintf(outfile, "\tNULL};\n");
	    fclose(outfile);
	}

	succeed(NULL);
    }

    return 0;
}