test/testautomation_rwops.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sun, 30 Dec 2012 19:05:50 -0800
changeset 6781 17a9b53a5ac3
parent 6779 c3b579c78059
child 6814 fccdef204fcf
permissions -rw-r--r--
Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
     1
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 * Automated SDL_RWops test.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
 * Original code written by Edgar Simo "bobbens"
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
 * Ported by Markus Kauppila (markus.kauppila@gmail.com)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
 * Updated for SDL_test by aschiffler at ferzkopp dot net
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
 * Released under Public Domain.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
/* quiet windows compiler warnings */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
#define _CRT_SECURE_NO_WARNINGS
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
#include <stdio.h>
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
#include "SDL.h"
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
#include "SDL_test.h"
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
/* ================= Test Case Implementation ================== */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
const char* RWopsReadTestFilename = "rwops_read";
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
const char* RWopsWriteTestFilename = "rwops_write";
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
static const char RWopsHelloWorldTestString[] = "Hello World!";
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
static const char RWopsHelloWorldCompString[] = "Hello World!";
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
/* Fixture */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
void
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
RWopsSetUp(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
	int fileLen = SDL_strlen(RWopsHelloWorldTestString);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
	FILE *handle;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
	int writtenLen;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
	int result;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
	/* Clean up from previous runs (if any); ignore errors */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
	remove(RWopsReadTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
	remove(RWopsWriteTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
	/* Create a test file */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
	handle = fopen(RWopsReadTestFilename, "w");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
	SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
    if (handle == NULL) return;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
	/* Write some known test into it */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
	writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
	SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
	result = fclose(handle);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
	SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
	SDLTest_AssertPass("Creation of test file completed");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
void
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
RWopsTearDown(void *arg)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
	int result;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
	
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
	/* Remove the created files to clean up; ignore errors for write filename */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
	result = remove(RWopsReadTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
	SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
	remove(RWopsWriteTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
	SDLTest_AssertPass("Cleanup of test files completed");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
 * @brief Makes sure parameters work properly. Local helper function.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
 * http://wiki.libsdl.org/moin.cgi/SDL_RWseek
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
 * http://wiki.libsdl.org/moin.cgi/SDL_RWread
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
void 
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
_testGenericRWopsValidations(SDL_RWops *rw, int write)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
   char buf[sizeof(RWopsHelloWorldTestString)];
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
    80
   Sint64 i;
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
   int seekPos = SDLTest_RandomIntegerInRange(4, 8);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
   /* Clear buffer */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
   SDL_zero(buf);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
   /* Set to start. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
    89
   SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
   /* Test write. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
   i = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
   SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
   if (write) {
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
    95
		SDLTest_AssertCheck(i == (Sint64)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", i);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
   }
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
   else {
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
    98
		SDLTest_AssertCheck(i != (Sint64)1, "Verify result of writing with SDL_RWwrite, expected !=1, got %i", i);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
   }
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
   /* Test seek to random position */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
   i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   104
   SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %i", seekPos, seekPos, i);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
   /* Test seek back to start */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
   i = SDL_RWseek(rw, 0, RW_SEEK_SET );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   109
   SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
   /* Test read */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
   i = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
   SDLTest_AssertPass("Call to SDL_RWread succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
   SDLTest_AssertCheck(
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   115
	   i == (Sint64)(sizeof(RWopsHelloWorldTestString)-1), 
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
	   "Verify result from SDL_RWread, expected %i, got %i",
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
	   sizeof(RWopsHelloWorldTestString)-1,
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   118
	   i);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
   SDLTest_AssertCheck(
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
	   SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, 
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   121
	   "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
   /* More seek tests. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   124
   i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
   SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
   SDLTest_AssertCheck(
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   127
	   i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), 
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   128
	   "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   129
	   sizeof(RWopsHelloWorldTestString)-5,
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
	   i);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
   i = SDL_RWseek( rw, -1, RW_SEEK_END );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
   SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
   SDLTest_AssertCheck(
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   135
	   i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), 
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
	   "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   137
	   sizeof(RWopsHelloWorldTestString)-2,
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
	   i);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   141
/*!
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
 * Negative test for SDL_RWFromFile parameters
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   146
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
rwops_testParamNegative (void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   150
   SDL_RWops *rwops;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   151
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
   /* These should all fail. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
   rwops = SDL_RWFromFile(NULL, NULL);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
   rwops = SDL_RWFromFile(NULL, "ab+");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
   rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
   SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
   rwops = SDL_RWFromFile("something", "");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   168
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   169
   rwops = SDL_RWFromFile("something", NULL);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   170
   SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   171
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   172
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   173
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   175
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   176
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
 * @brief Tests opening from memory.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   180
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   181
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   182
rwops_testMem (void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   183
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   184
   char mem[sizeof(RWopsHelloWorldTestString)];
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   185
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   186
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   187
   /* Clear buffer */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   188
   SDL_zero(mem);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   189
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   190
   /* Open */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   191
   rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   192
   SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   194
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
   /* Bail out if NULL */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
   if (rw == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
   _testGenericRWopsValidations(rw, 1);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   200
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   201
   /* Close */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   205
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   206
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   207
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   208
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   210
 * @brief Tests opening from memory.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   211
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   212
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   213
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   215
int 
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
rwops_testConstMem (void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   218
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   219
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   220
   /* Open handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   221
   rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   222
   SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   223
   SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   224
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   225
   /* Bail out if NULL */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   226
   if (rw == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   227
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   228
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   229
   _testGenericRWopsValidations( rw, 0 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   230
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   231
   /* Close handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   234
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   235
  return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   236
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   237
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   238
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   239
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   240
 * @brief Tests reading from file.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   241
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   242
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   243
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   244
 * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   245
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   246
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   247
rwops_testFileRead(void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   248
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   249
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   250
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   251
   /* Read test. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   252
   rw = SDL_RWFromFile(RWopsReadTestFilename, "r");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   253
   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   254
   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   255
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   256
   // Bail out if NULL
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   257
   if (rw == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   258
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   259
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   260
   _testGenericRWopsValidations( rw, 0 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   261
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   262
   /* Close handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   264
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   265
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   266
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   267
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   268
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   269
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   270
 * @brief Tests writing from memory.
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   271
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   272
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   273
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   274
 * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   275
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   276
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   277
rwops_testFileWrite(void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   278
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   279
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   280
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   281
   /* Write test. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   282
   rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   283
   SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   284
   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   285
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   286
   // Bail out if NULL
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   287
   if (rw == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   288
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   289
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   290
   _testGenericRWopsValidations( rw, 1 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   291
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   292
   /* Close handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   293
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   294
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   295
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   296
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   297
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   298
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   299
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   300
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   301
 * @brief Tests reading from file handle
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   302
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   303
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   304
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   305
 * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   306
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   307
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   308
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   309
rwops_testFPRead(void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   310
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   311
   FILE *fp;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   312
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   313
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   314
   /* Run read tests. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   315
   fp = fopen(RWopsReadTestFilename, "r");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   316
   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   317
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   318
   /* Bail out if NULL */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   319
   if (fp == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   320
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   321
   /* Open */
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   322
   rw = SDL_RWFromFP( fp, SDL_TRUE );
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   323
   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   324
   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   325
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   326
   /* Bail out if NULL */
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   327
   if (rw == NULL) {
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   328
     fclose(fp);
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   329
     return TEST_ABORTED;
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   330
   }
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   331
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   332
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   333
   _testGenericRWopsValidations( rw, 0 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   334
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   335
   /* Close handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   336
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   337
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   338
   fclose(fp);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   339
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   340
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   341
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   342
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   343
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   344
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   345
 * @brief Tests writing to file handle
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   346
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   347
 * \sa
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   348
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   349
 * http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   350
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   351
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   352
int
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   353
rwops_testFPWrite(void)
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   354
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   355
   FILE *fp;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   356
   SDL_RWops *rw;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   357
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   358
   /* Run write tests. */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   359
   fp = fopen(RWopsWriteTestFilename, "w+");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   360
   SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   361
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   362
   /* Bail out if NULL */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   363
   if (fp == NULL) return TEST_ABORTED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   364
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   365
   /* Open */
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6769
diff changeset
   366
   rw = SDL_RWFromFP( fp, SDL_TRUE );
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   367
   SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   368
   SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   369
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   370
   /* Bail out if NULL */
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   371
   if (rw == NULL) {
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   372
     fclose(fp);
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   373
     return TEST_ABORTED;
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   374
   }
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   375
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   376
   /* Run generic tests */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   377
   _testGenericRWopsValidations( rw, 1 );
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   378
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   379
   /* Close handle */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   380
   SDL_RWclose(rw);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   381
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   382
   fclose(fp);
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   383
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   384
   return TEST_COMPLETED;
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   385
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   386
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   387
/**
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   388
 * @brief Tests alloc and free RW context.
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   389
 *
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   390
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   391
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_AllocRW
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   392
 */
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   393
int
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   394
rwops_testAllocFree (void)
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   395
{
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   396
   /* Allocate context */
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   397
   SDL_RWops *rw = SDL_AllocRW();
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   398
   SDLTest_AssertPass("Call to SDL_AllocRW() succeeded");
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   399
   SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL");
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   400
   if (rw==NULL) return TEST_ABORTED;
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   401
          
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   402
   /* Free context again */
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   403
   SDL_FreeRW(rw);
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   404
   SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   405
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   406
   return TEST_COMPLETED;
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   407
}
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   408
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   409
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   410
/* ================= Test References ================== */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   411
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   412
/* RWops test cases */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   413
static const SDLTest_TestCaseReference rwopsTest1 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   414
		{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   415
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   416
static const SDLTest_TestCaseReference rwopsTest2 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   417
		{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   418
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   419
static const SDLTest_TestCaseReference rwopsTest3 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   420
		{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   421
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   422
static const SDLTest_TestCaseReference rwopsTest4 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   423
		{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   424
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   425
static const SDLTest_TestCaseReference rwopsTest5 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   426
		{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   427
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   428
static const SDLTest_TestCaseReference rwopsTest6 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   429
		{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   430
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   431
static const SDLTest_TestCaseReference rwopsTest7 =
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   432
		{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   433
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   434
static const SDLTest_TestCaseReference rwopsTest8 =
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   435
		{ (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED };
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   436
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   437
/* Sequence of RWops test cases */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   438
static const SDLTest_TestCaseReference *rwopsTests[] =  {
6781
17a9b53a5ac3 Fix incorrect use of SDL_FreeRW in rwops suite; add testcase for SDL_AllocRW/SDL_FreeRW to rwops test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
   439
	&rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, &rwopsTest7, &rwopsTest8, NULL
6760
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   440
};
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   441
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   442
/* RWops test suite (global) */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   443
SDLTest_TestSuiteReference rwopsTestSuite = {
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   444
	"RWops",
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   445
	RWopsSetUp,
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   446
	rwopsTests,
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   447
	RWopsTearDown
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   448
};