test/test-automation/tests/testdummy/testdummy.c
author Markus Kauppila <markus.kauppila@gmail.com>
Sun, 14 Aug 2011 21:05:08 +0300
changeset 5830 e1a6cc820772
parent 5828 8d47a4260d5d
child 5833 48dcdbf3dbc2
permissions -rw-r--r--
Updating dummy test suite.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     1
/*
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     2
  Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     3
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     4
  This software is provided 'as-is', without any express or implied
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     6
  arising from the use of this software.
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     7
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    10
  freely, subject to the following restrictions:
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    11
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    12
  1. The origin of this software must not be misrepresented; you must not
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    13
     claim that you wrote the original software. If you use this software
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    14
     in a product, an acknowledgment in the product documentation would be
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    15
     appreciated but is not required.
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    16
  2. Altered source versions must be plainly marked as such, and must not be
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    17
     misrepresented as being the original software.
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    18
  3. This notice may not be removed or altered from any source distribution.
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    19
*/
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    20
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    21
/*! \file
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    22
 * Dummy test suite for test runner. This can be used as a base for
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    23
 * writing new tests. Dummy suite also works as reference to using
5754
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    24
 * various asserts and other (possible) utilities.
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    25
 */
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    26
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    27
#include <stdio.h>
5799
75098354c725 Added functions that generate random boundary values
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5798
diff changeset
    28
#include <stdint.h>
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    29
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    30
#include <SDL/SDL.h>
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    31
5804
d82711e39c05 Reorganizing the project.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5802
diff changeset
    32
#include "../../include/SDL_test.h"
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    33
5820
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
    34
#include <limits.h>
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
    35
5688
bbc19d6aaddb Add a comment.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5686
diff changeset
    36
/* Test case references */
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    37
static const TestCaseReference test1 =
5758
e497802a71b4 Harness kills hung tests (won't work with --in-proc option).
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5756
diff changeset
    38
		(TestCaseReference){ "dummycase1", "description", TEST_ENABLED, 0, 4};
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    39
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    40
static const TestCaseReference test2 =
5698
811b5480850e Added timeout to TestCaseReference.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5694
diff changeset
    41
		(TestCaseReference){ "dummycase2", "description", TEST_ENABLED, 0, 0};
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    42
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    43
static const TestCaseReference test3 =
5830
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
    44
		(TestCaseReference){ "testfuzzy_case3", "description", TEST_ENABLED, 0, 2};
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
    45
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
    46
static const TestCaseReference test4 =
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
    47
		(TestCaseReference){ "testfuzzy_case4", "description", TEST_ENABLED, 0, 2};
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    48
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    49
/* Test suite */
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    50
extern const TestCaseReference *testSuite[] =  {
5830
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
    51
	&test1, &test2, &test3, &test4, NULL
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    52
};
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    53
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    54
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    55
TestCaseReference **QueryTestSuite() {
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    56
	return (TestCaseReference **)testSuite;
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    57
}
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    58
5754
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    59
/* Create test fixture */
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    60
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    61
/*!
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    62
 * SetUp function can be used to create a test fixture for test cases.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    63
 * The function will be called right before executing the test case.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    64
 *
5755
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5754
diff changeset
    65
 * Note: If any assert in the function fails then the test will be skipped.
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5754
diff changeset
    66
 * In practice, the entire suite will be skipped if assert failure happens.
35d4ae5dea90 If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5754
diff changeset
    67
 *
5754
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    68
 * Note: this function is optional.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    69
 *
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    70
 * \param arg parameters given to test. Usually NULL
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    71
 */
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    72
void
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    73
SetUp(void *arg)
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    74
{
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    75
	// create test fixture,
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    76
	// for example, set up static variables used by test cases here
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    77
}
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    78
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    79
/*!
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    80
 * TearDown function can be used to destroy a test fixture for test cases.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    81
 * The function will be called right after executing the test case.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    82
 *
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    83
 * Note: this function is optional.
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    84
 *
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    85
 * \param arg parameters given to test. Usually NULL
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    86
 */
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    87
void
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    88
TearDown(void *arg)
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    89
{
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    90
	// destroy test fixture
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    91
}
2eead798346a Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5751
diff changeset
    92
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    93
/* Test case functions */
5694
2fc30d9b1002 Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5692
diff changeset
    94
void
2fc30d9b1002 Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5692
diff changeset
    95
dummycase1(void *arg)
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    96
{
5759
59615ddece72 Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5758
diff changeset
    97
	AssertEquals(5, 5, "Assert message");
5780
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
    98
5798
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
    99
	/*
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   100
	for( ; 1 ; )
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   101
		Log(0, "uint8 (same value): %u", RandomPositiveInteger());
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   102
	// */
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   103
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   104
	//Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE));
40d11e399784 Refining boundary value generator.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5785
diff changeset
   105
5825
9dd4fa61d5cc Cleaned up the rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5824
diff changeset
   106
	for(; 0 ; )
5824
5205ba7c497c Added random number generators for Uint8, Sint8, Uint16, Sint16,
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5821
diff changeset
   107
		printf("%d\n", RandomSint16());
5820
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   108
5821
717e4cb840dd Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5820
diff changeset
   109
	for( ; 0 ; ) {
5820
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   110
		//Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE));
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   111
		//Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE));
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   112
		Log(0, "sint32: %d", RandomSint32BoundaryValue(INT_MIN, 3000, SDL_FALSE));
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   113
		//Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE));
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   114
	}
293fed907724 Refactored the fuzzer a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5804
diff changeset
   115
5802
ca0c0d5e56c6 Cleaned the dummy suite a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5799
diff changeset
   116
	for(; 0 ;) {
5799
75098354c725 Added functions that generate random boundary values
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5798
diff changeset
   117
		//Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE));
75098354c725 Added functions that generate random boundary values
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5798
diff changeset
   118
		//Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE));
75098354c725 Added functions that generate random boundary values
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5798
diff changeset
   119
		//Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE));
75098354c725 Added functions that generate random boundary values
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5798
diff changeset
   120
		Log(0, "int64: %llu", RandomUint64BoundaryValue(2, 0xFFFFFFFFFFFFFFFE, SDL_FALSE));
5782
3e6c6c39f908 Refining the fuzzer. Adding new functions and fixing the old ones.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5780
diff changeset
   121
	}
3e6c6c39f908 Refining the fuzzer. Adding new functions and fixing the old ones.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5780
diff changeset
   122
5780
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   123
	for(; 0 ;) {
5782
3e6c6c39f908 Refining the fuzzer. Adding new functions and fixing the old ones.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5780
diff changeset
   124
		int min = -5;
3e6c6c39f908 Refining the fuzzer. Adding new functions and fixing the old ones.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5780
diff changeset
   125
		int max = 5;
5783
236ed35e4b34 Logger logs harness seed and test execution keys in hex representation.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5782
diff changeset
   126
		int random =  RandomIntegerInRange(min, max);
5780
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   127
		if(random < min || random > max ) {
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   128
			AssertFail("Generated incorrect integer");
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   129
		}
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   130
		Log(0, "%d", random);
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   131
	}
6d294a397a27 Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5777
diff changeset
   132
5785
7fc252ce5d1d Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5784
diff changeset
   133
	//Log(0, "Random: %s", RandomAsciiString());
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   134
}
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   135
5694
2fc30d9b1002 Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5692
diff changeset
   136
void
2fc30d9b1002 Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5692
diff changeset
   137
dummycase2(void *arg)
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   138
{
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   139
	char *msg = "eello";
5777
e52f6ba69eef Fixed linking issue concerning test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5770
diff changeset
   140
	//msg[0] = 'H';
5751
cbb921210496 Bunch of little fixes.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5718
diff changeset
   141
	AssertTrue(1, "Assert message");
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   142
}
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   143
5694
2fc30d9b1002 Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5692
diff changeset
   144
void
5830
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   145
testfuzzy_case3(void *arg)
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   146
{
5830
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   147
	// Simulates a fuzzing failure
5828
8d47a4260d5d Ported tests from "./tests/automated/render"
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5825
diff changeset
   148
	AssertTrue(RandomUint8() != 100, "Value is 100");
5686
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   149
}
a7d699502230 Converted libtest to a more proper dummy test suite (libtestdummy).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   150
5830
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   151
static void
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   152
f(void) {
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   153
     int* x = malloc(10 * sizeof(int));
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   154
     x[10] = 0;        // problem 1: heap block overrun
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   155
}                    // problem 2: memory leak -- x not freed
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   156
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   157
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   158
void
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   159
testfuzzy_case4(void *arg)
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   160
{
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   161
	// Creates a memory leak
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   162
	f();
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   163
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   164
	AssertPass("");
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   165
}
e1a6cc820772 Updating dummy test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5828
diff changeset
   166