test/test-automation/tests/testdummy/testdummy.c
changeset 5830 e1a6cc820772
parent 5828 8d47a4260d5d
child 5833 48dcdbf3dbc2
equal deleted inserted replaced
5829:12920d41301d 5830:e1a6cc820772
    39 
    39 
    40 static const TestCaseReference test2 =
    40 static const TestCaseReference test2 =
    41 		(TestCaseReference){ "dummycase2", "description", TEST_ENABLED, 0, 0};
    41 		(TestCaseReference){ "dummycase2", "description", TEST_ENABLED, 0, 0};
    42 
    42 
    43 static const TestCaseReference test3 =
    43 static const TestCaseReference test3 =
    44 		(TestCaseReference){ "dummycase3", "description", TEST_ENABLED, 0, 2};
    44 		(TestCaseReference){ "testfuzzy_case3", "description", TEST_ENABLED, 0, 2};
       
    45 
       
    46 static const TestCaseReference test4 =
       
    47 		(TestCaseReference){ "testfuzzy_case4", "description", TEST_ENABLED, 0, 2};
    45 
    48 
    46 /* Test suite */
    49 /* Test suite */
    47 extern const TestCaseReference *testSuite[] =  {
    50 extern const TestCaseReference *testSuite[] =  {
    48 	&test1, &test2, &test3, NULL
    51 	&test1, &test2, &test3, &test4, NULL
    49 };
    52 };
    50 
    53 
    51 
    54 
    52 TestCaseReference **QueryTestSuite() {
    55 TestCaseReference **QueryTestSuite() {
    53 	return (TestCaseReference **)testSuite;
    56 	return (TestCaseReference **)testSuite;
   137 	//msg[0] = 'H';
   140 	//msg[0] = 'H';
   138 	AssertTrue(1, "Assert message");
   141 	AssertTrue(1, "Assert message");
   139 }
   142 }
   140 
   143 
   141 void
   144 void
   142 dummycase3(void *arg)
   145 testfuzzy_case3(void *arg)
   143 {
   146 {
       
   147 	// Simulates a fuzzing failure
   144 	AssertTrue(RandomUint8() != 100, "Value is 100");
   148 	AssertTrue(RandomUint8() != 100, "Value is 100");
   145 }
   149 }
   146 
   150 
       
   151 static void
       
   152 f(void) {
       
   153      int* x = malloc(10 * sizeof(int));
       
   154      x[10] = 0;        // problem 1: heap block overrun
       
   155 }                    // problem 2: memory leak -- x not freed
       
   156 
       
   157 
       
   158 void
       
   159 testfuzzy_case4(void *arg)
       
   160 {
       
   161 	// Creates a memory leak
       
   162 	f();
       
   163 
       
   164 	AssertPass("");
       
   165 }
       
   166