test/testautomation_rwops.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 9260 039714172dc3
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
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)
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
     7
 * Updated and extended for SDL_test by aschiffler at ferzkopp dot net
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
     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";
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
    24
const char* RWopsAlphabetFilename = "rwops_alphabet";
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
    25
04dcce3081e6 Port clipboard 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 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
    27
static const char RWopsHelloWorldCompString[] = "Hello World!";
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
    28
static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
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
    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
/* 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
    31
04dcce3081e6 Port clipboard 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
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
    33
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
    34
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    35
    int fileLen;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    36
    FILE *handle;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    37
    int writtenLen;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    38
    int result;
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
    39
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    40
    /* Clean up from previous runs (if any); ignore errors */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    41
    remove(RWopsReadTestFilename);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    42
    remove(RWopsWriteTestFilename);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    43
    remove(RWopsAlphabetFilename);
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
    44
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    45
    /* Create a test file */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    46
    handle = fopen(RWopsReadTestFilename, "w");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    47
    SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
    48
        if (handle == NULL) return;
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
    49
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    50
    /* Write some known text into it */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    51
    fileLen = SDL_strlen(RWopsHelloWorldTestString);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    52
    writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    53
    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    54
    result = fclose(handle);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    55
    SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
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
    56
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    57
    /* Create a second test file */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    58
    handle = fopen(RWopsAlphabetFilename, "w");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    59
    SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename);
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
    60
        if (handle == NULL) return;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
    61
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    62
    /* Write alphabet text into it */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    63
    fileLen = SDL_strlen(RWopsAlphabetString);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    64
    writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    65
    SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    66
    result = fclose(handle);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    67
    SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
    68
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    69
    SDLTest_AssertPass("Creation of test file completed");
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
    70
}
04dcce3081e6 Port clipboard 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
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
    73
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
    74
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    75
    int result;
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
    76
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    77
    /* Remove the created files to clean up; ignore errors for write filename */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    78
    result = remove(RWopsReadTestFilename);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    79
    SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    80
    remove(RWopsWriteTestFilename);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    81
    result = remove(RWopsAlphabetFilename);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    82
    SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    83
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    84
    SDLTest_AssertPass("Cleanup of test files completed");
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
    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
04dcce3081e6 Port clipboard 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
/**
04dcce3081e6 Port clipboard 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
 * @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
    89
 *
04dcce3081e6 Port clipboard 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
 * \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
    91
 * 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
    92
 * 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
    93
 */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
    94
void
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
    95
_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
    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
   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
    98
   Sint64 i;
6996
bc0fd5bced25 Fix bug 1560 - SDL_RWFromConstMem write operation returns -1 but should return 0.
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
    99
   size_t s;
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
   100
   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
   101
04dcce3081e6 Port clipboard 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
   /* 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
   103
   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
   104
04dcce3081e6 Port clipboard 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
   /* 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
   106
   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
   107
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   108
   SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, 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
   109
04dcce3081e6 Port clipboard 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
   /* Test write. */
6996
bc0fd5bced25 Fix bug 1560 - SDL_RWFromConstMem write operation returns -1 but should return 0.
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   111
   s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 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
   112
   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
   113
   if (write) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   114
        SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s);
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
   115
   }
04dcce3081e6 Port clipboard 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
   else {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   117
        SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s);
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
   118
   }
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
   /* 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
   121
   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
   122
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   123
   SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %"SDL_PRIs64, 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
   124
04dcce3081e6 Port clipboard 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
   /* 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
   126
   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
   127
   SDLTest_AssertPass("Call to SDL_RWseek succeeded");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   128
   SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, 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
   129
04dcce3081e6 Port clipboard 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
   /* Test read */
6996
bc0fd5bced25 Fix bug 1560 - SDL_RWFromConstMem write operation returns -1 but should return 0.
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   131
   s = SDL_RWread( rw, buf, 1, 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
   132
   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
   133
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   134
       s == (size_t)(sizeof(RWopsHelloWorldTestString)-1),
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   135
       "Verify result from SDL_RWread, expected %i, got %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   136
       sizeof(RWopsHelloWorldTestString)-1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   137
       s);
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
   138
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   139
       SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   140
       "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
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
   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
   /* 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
   143
   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
   144
   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
   145
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   146
       i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   147
       "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %"SDL_PRIs64,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   148
       sizeof(RWopsHelloWorldTestString)-5,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   149
       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
   150
04dcce3081e6 Port clipboard 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
   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
   152
   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
   153
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   154
       i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   155
       "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %"SDL_PRIs64,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   156
       sizeof(RWopsHelloWorldTestString)-2,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   157
       i);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   158
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   159
   /* Invalid whence seek */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   160
   i = SDL_RWseek( rw, 0, 999 );
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   161
   SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   162
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   163
       i == (Sint64)(-1),
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   164
       "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %"SDL_PRIs64,
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   165
       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
   166
}
04dcce3081e6 Port clipboard 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
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
   168
/* !
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
   169
 * 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
   170
 *
04dcce3081e6 Port clipboard 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
 * \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
   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
 */
04dcce3081e6 Port clipboard 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
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
   175
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
   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
   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
   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
   /* 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
   180
   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
   181
   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
   182
   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
   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
   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
   185
   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
   186
   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
   187
04dcce3081e6 Port clipboard 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
   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
   189
   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
   190
   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
   191
04dcce3081e6 Port clipboard 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
   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
   193
   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
   194
   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
   195
04dcce3081e6 Port clipboard 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
   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
   197
   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
   198
   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
   199
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   200
   rwops = SDL_RWFromMem((void *)NULL, 10);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   201
   SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   202
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   203
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   204
   rwops = SDL_RWFromMem((void *)RWopsAlphabetString, 0);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   205
   SDLTest_AssertPass("Call to SDL_RWFromMem(data, 0) succeeded");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   206
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(data, 0) returns NULL");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   207
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   208
   rwops = SDL_RWFromConstMem((const void *)RWopsAlphabetString, 0);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   209
   SDLTest_AssertPass("Call to SDL_RWFromConstMem(data, 0) succeeded");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   210
   SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromConstMem(data, 0) returns NULL");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   211
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
   212
   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
   213
}
04dcce3081e6 Port clipboard 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
/**
04dcce3081e6 Port clipboard 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
 * @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
   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
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   219
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   220
 */
04dcce3081e6 Port clipboard 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
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
   222
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
   223
{
04dcce3081e6 Port clipboard 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
   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
   225
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   226
   int result;
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
   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
   /* 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
   229
   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
   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
   /* 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
   232
   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
   233
   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
   234
   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
   235
04dcce3081e6 Port clipboard 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
   /* 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
   237
   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
   238
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   239
   /* Check type */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   240
   SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %d", SDL_RWOPS_MEMORY, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   241
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
   242
   /* 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
   243
   _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
   244
04dcce3081e6 Port clipboard 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
   /* Close */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   246
   result = SDL_RWclose(rw);
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
   247
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   248
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   249
04dcce3081e6 Port clipboard 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
   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
   251
}
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
/**
04dcce3081e6 Port clipboard 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
 * @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
   256
 *
04dcce3081e6 Port clipboard 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
 * \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
   258
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   259
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   260
 */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   261
int
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
   262
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
   263
{
04dcce3081e6 Port clipboard 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
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   265
   int result;
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
   266
04dcce3081e6 Port clipboard 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
   /* 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
   268
   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
   269
   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
   270
   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
   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
   /* 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
   273
   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
   274
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   275
   /* Check type */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   276
   SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %d", SDL_RWOPS_MEMORY_RO, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   277
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
   278
   /* 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
   279
   _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
   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
   /* Close handle */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   282
   result = SDL_RWclose(rw);
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
   283
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   284
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   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
  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
   287
}
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
/**
04dcce3081e6 Port clipboard 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
 * @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
   292
 *
04dcce3081e6 Port clipboard 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
 * \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
   294
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   295
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   296
 */
04dcce3081e6 Port clipboard 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
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
   298
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
   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
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   301
   int result;
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
   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
   /* 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
   304
   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
   305
   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
   306
   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
   307
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   308
   /* Bail out if 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
   309
   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
   310
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   311
   /* Check type */
8761
bce4122e6e87 __ANDROID__ is the correct macro to check for an android system.ANDROID is only defined in NDK build system (.mk) and not in the standalone NDK.
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 7678
diff changeset
   312
#if defined(__ANDROID__)
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   313
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   314
      rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   315
      "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   316
#elif defined(__WIN32__)
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   317
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   318
      rw->type == SDL_RWOPS_WINFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   319
      "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   320
#else
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   321
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   322
      rw->type == SDL_RWOPS_STDFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   323
      "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   324
#endif
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   325
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
   326
   /* 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
   327
   _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
   328
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   329
   /* Close handle */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   330
   result = SDL_RWclose(rw);
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
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   332
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   333
04dcce3081e6 Port clipboard 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
   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
   335
}
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
/**
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   338
 * @brief Tests writing from file.
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
   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
 * \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
   341
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   342
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   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
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
   345
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
   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
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   348
   int result;
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
   349
04dcce3081e6 Port clipboard 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
   /* 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
   351
   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
   352
   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
   353
   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
   354
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   355
   /* Bail out if 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
   356
   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
   357
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   358
   /* Check type */
8761
bce4122e6e87 __ANDROID__ is the correct macro to check for an android system.ANDROID is only defined in NDK build system (.mk) and not in the standalone NDK.
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 7678
diff changeset
   359
#if defined(__ANDROID__)
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   360
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   361
      rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   362
      "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   363
#elif defined(__WIN32__)
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   364
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   365
      rw->type == SDL_RWOPS_WINFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   366
      "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   367
#else
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   368
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   369
      rw->type == SDL_RWOPS_STDFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   370
      "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   371
#endif
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   372
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
   373
   /* 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
   374
   _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
   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
   /* Close handle */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   377
   result = SDL_RWclose(rw);
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
   378
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   379
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   380
04dcce3081e6 Port clipboard 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
   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
   382
}
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard 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
 * @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
   387
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   388
 * \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
   389
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   390
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   391
 *
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   392
 */
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   393
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
   394
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
   395
{
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   396
   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
   397
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   398
   int result;
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
   399
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   400
   /* 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
   401
   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
   402
   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
   403
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   404
   /* 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
   405
   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
   406
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   407
   /* 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
   408
   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
   409
   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
   410
   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
   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
   /* 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
   413
   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
   414
     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
   415
     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
   416
   }
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
   417
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   418
   /* Check type */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   419
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   420
      rw->type == SDL_RWOPS_STDFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   421
      "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   422
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
   423
   /* 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
   424
   _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
   425
6814
fccdef204fcf Fix RWops test suite crash on Linux: remove unnecessary fclose
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6781
diff changeset
   426
   /* Close handle - does fclose() */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   427
   result = SDL_RWclose(rw);
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
   428
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   429
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   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
   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
   432
}
04dcce3081e6 Port clipboard 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
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   434
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   435
/**
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   436
 * @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
   437
 *
04dcce3081e6 Port clipboard 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
 * \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
   439
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   440
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
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
   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
 */
04dcce3081e6 Port clipboard 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
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
   444
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
   445
{
04dcce3081e6 Port clipboard 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
   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
   447
   SDL_RWops *rw;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   448
   int result;
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
   449
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   450
   /* 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
   451
   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
   452
   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
   453
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   454
   /* 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
   455
   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
   456
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   457
   /* 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
   458
   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
   459
   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
   460
   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
   461
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   462
   /* 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
   463
   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
   464
     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
   465
     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
   466
   }
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
   467
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   468
   /* Check type */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   469
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   470
      rw->type == SDL_RWOPS_STDFILE,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   471
      "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   472
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
   473
   /* 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
   474
   _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
   475
6814
fccdef204fcf Fix RWops test suite crash on Linux: remove unnecessary fclose
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6781
diff changeset
   476
   /* Close handle - does fclose() */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   477
   result = SDL_RWclose(rw);
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
   478
   SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   479
   SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
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
   480
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   481
   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
   482
}
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   483
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
   484
/**
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
   485
 * @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
   486
 *
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   487
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_AllocRW
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
   488
 * \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
   489
 */
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
   490
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
   491
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
   492
{
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
   493
   /* 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
   494
   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
   495
   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
   496
   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
   497
   if (rw==NULL) return TEST_ABORTED;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   498
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   499
   /* Check type */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   500
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   501
      rw->type == SDL_RWOPS_UNKNOWN,
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   502
      "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %d", SDL_RWOPS_UNKNOWN, rw->type);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   503
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
   504
   /* 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
   505
   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
   506
   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
   507
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
   508
   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
   509
}
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
   510
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   511
/**
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   512
 * @brief Compare memory and file reads
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   513
 *
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   514
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   515
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   516
 */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   517
int
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   518
rwops_testCompareRWFromMemWithRWFromFile(void)
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   519
{
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   520
   int slen = 26;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   521
   char buffer_file[27];
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   522
   char buffer_mem[27];
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   523
   size_t rv_file;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   524
   size_t rv_mem;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   525
   Uint64 sv_file;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   526
   Uint64 sv_mem;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   527
   SDL_RWops* rwops_file;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   528
   SDL_RWops* rwops_mem;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   529
   int size;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   530
   int result;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   531
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   532
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   533
   for (size=5; size<10; size++)
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   534
   {
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   535
     /* Terminate buffer */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   536
     buffer_file[slen] = 0;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   537
     buffer_mem[slen] = 0;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   538
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   539
     /* Read/seek from memory */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   540
     rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   541
     SDLTest_AssertPass("Call to SDL_RWFromMem()");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   542
     rv_mem = SDL_RWread(rwops_mem, buffer_mem, size, 6);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   543
     SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   544
     sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   545
     SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   546
     result = SDL_RWclose(rwops_mem);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   547
     SDLTest_AssertPass("Call to SDL_RWclose(mem)");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   548
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   549
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   550
     /* Read/see from file */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   551
     rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   552
     SDLTest_AssertPass("Call to SDL_RWFromFile()");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   553
     rv_file = SDL_RWread(rwops_file, buffer_file, size, 6);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   554
     SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   555
     sv_file = SDL_RWseek(rwops_file, 0, SEEK_END);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   556
     SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   557
     result = SDL_RWclose(rwops_file);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   558
     SDLTest_AssertPass("Call to SDL_RWclose(file)");
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   559
     SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   560
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   561
     /* Compare */
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   562
     SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file);
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   563
     SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%"SDL_PRIu64" sv_file=%"SDL_PRIu64, sv_mem, sv_file);
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   564
     SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   565
     SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   566
     SDLTest_AssertCheck(
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   567
       SDL_strncmp(buffer_mem, RWopsAlphabetString, slen) == 0,
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   568
       "Verify mem buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_mem);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   569
     SDLTest_AssertCheck(
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   570
       SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0,
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   571
       "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file);
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   572
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   573
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   574
   return TEST_COMPLETED;
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   575
}
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   576
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   577
/**
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   578
 * @brief Tests writing and reading from file using endian aware functions.
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   579
 *
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   580
 * \sa
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   581
 * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   582
 * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   583
 * http://wiki.libsdl.org/moin.cgi/SDL_ReadBE16
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   584
 * http://wiki.libsdl.org/moin.cgi/SDL_WriteBE16
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   585
 */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   586
int
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   587
rwops_testFileWriteReadEndian(void)
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   588
{
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   589
   SDL_RWops *rw;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6819
diff changeset
   590
   Sint64 result;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   591
   int mode;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   592
   size_t objectsWritten;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   593
   Uint16 BE16value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   594
   Uint32 BE32value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   595
   Uint64 BE64value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   596
   Uint16 LE16value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   597
   Uint32 LE32value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   598
   Uint64 LE64value;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   599
   Uint16 BE16test;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   600
   Uint32 BE32test;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   601
   Uint64 BE64test;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   602
   Uint16 LE16test;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   603
   Uint32 LE32test;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   604
   Uint64 LE64test;
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   605
   int cresult;
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   606
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   607
   for (mode = 0; mode < 3; mode++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   608
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   609
     /* Create test data */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   610
     switch (mode) {
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   611
       case 0:
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   612
        SDLTest_Log("All 0 values");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   613
        BE16value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   614
        BE32value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   615
        BE64value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   616
        LE16value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   617
        LE32value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   618
        LE64value = 0;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   619
        break;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   620
       case 1:
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   621
        SDLTest_Log("All 1 values");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   622
        BE16value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   623
        BE32value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   624
        BE64value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   625
        LE16value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   626
        LE32value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   627
        LE64value = 1;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   628
        break;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   629
       case 2:
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   630
        SDLTest_Log("Random values");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   631
        BE16value = SDLTest_RandomUint16();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   632
        BE32value = SDLTest_RandomUint32();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   633
        BE64value = SDLTest_RandomUint64();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   634
        LE16value = SDLTest_RandomUint16();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   635
        LE32value = SDLTest_RandomUint32();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   636
        LE64value = SDLTest_RandomUint64();
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   637
        break;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   638
     }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   639
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   640
     /* Write test. */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   641
     rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   642
     SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   643
     SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   644
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   645
     /* Bail out if NULL */
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   646
     if (rw == NULL) return TEST_ABORTED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   647
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   648
     /* Write test data */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   649
     objectsWritten = SDL_WriteBE16(rw, BE16value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   650
     SDLTest_AssertPass("Call to SDL_WriteBE16()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   651
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   652
     objectsWritten = SDL_WriteBE32(rw, BE32value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   653
     SDLTest_AssertPass("Call to SDL_WriteBE32()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   654
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   655
     objectsWritten = SDL_WriteBE64(rw, BE64value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   656
     SDLTest_AssertPass("Call to SDL_WriteBE64()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   657
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   658
     objectsWritten = SDL_WriteLE16(rw, LE16value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   659
     SDLTest_AssertPass("Call to SDL_WriteLE16()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   660
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   661
     objectsWritten = SDL_WriteLE32(rw, LE32value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   662
     SDLTest_AssertPass("Call to SDL_WriteLE32()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   663
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   664
     objectsWritten = SDL_WriteLE64(rw, LE64value);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   665
     SDLTest_AssertPass("Call to SDL_WriteLE64()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   666
     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   667
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   668
     /* Test seek to start */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   669
     result = SDL_RWseek( rw, 0, RW_SEEK_SET );
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   670
     SDLTest_AssertPass("Call to SDL_RWseek succeeded");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   671
     SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %"SDL_PRIs64, result);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   672
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   673
     /* Read test data */
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   674
     BE16test = SDL_ReadBE16(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   675
     SDLTest_AssertPass("Call to SDL_ReadBE16()");
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   676
     SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   677
     BE32test = SDL_ReadBE32(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   678
     SDLTest_AssertPass("Call to SDL_ReadBE32()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   679
     SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   680
     BE64test = SDL_ReadBE64(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   681
     SDLTest_AssertPass("Call to SDL_ReadBE64()");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   682
     SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, BE64value, BE64test);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   683
     LE16test = SDL_ReadLE16(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   684
     SDLTest_AssertPass("Call to SDL_ReadLE16()");
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   685
     SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   686
     LE32test = SDL_ReadLE32(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   687
     SDLTest_AssertPass("Call to SDL_ReadLE32()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   688
     SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   689
     LE64test = SDL_ReadLE64(rw);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8761
diff changeset
   690
     SDLTest_AssertPass("Call to SDL_ReadLE64()");
9260
039714172dc3 switch to use SDL_PRI* macros for long long formatting everywhere.
Edward Rudd <urkle@outoforder.cc>
parents: 9254
diff changeset
   691
     SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, LE64value, LE64test);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   692
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   693
     /* Close handle */
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   694
     cresult = SDL_RWclose(rw);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   695
     SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   696
     SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   697
   }
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   698
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   699
   return TEST_COMPLETED;
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   700
}
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   701
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
   702
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
   703
/* ================= 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
   704
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   705
/* 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
   706
static const SDLTest_TestCaseReference rwopsTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   707
        { (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
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
   708
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   709
static const SDLTest_TestCaseReference rwopsTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   710
        { (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
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
   711
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   712
static const SDLTest_TestCaseReference rwopsTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   713
        { (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
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
   714
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   715
static const SDLTest_TestCaseReference rwopsTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   716
        { (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
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
   717
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   718
static const SDLTest_TestCaseReference rwopsTest5 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   719
        { (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
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
   720
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   721
static const SDLTest_TestCaseReference rwopsTest6 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   722
        { (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
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
   723
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   724
static const SDLTest_TestCaseReference rwopsTest7 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   725
        { (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
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
   726
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
   727
static const SDLTest_TestCaseReference rwopsTest8 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   728
        { (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED };
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
   729
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   730
static const SDLTest_TestCaseReference rwopsTest9 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   731
        { (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED };
6819
afef68703f54 Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6814
diff changeset
   732
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   733
static const SDLTest_TestCaseReference rwopsTest10 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   734
        { (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED };
6999
681820ca0e78 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6996
diff changeset
   735
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
   736
/* 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
   737
static const SDLTest_TestCaseReference *rwopsTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   738
    &rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   739
    &rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, 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
   740
};
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   741
04dcce3081e6 Port clipboard and rwops test suites from GSOC code; minor updates to harness and fuzzer in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   742
/* 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
   743
SDLTest_TestSuiteReference rwopsTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   744
    "RWops",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   745
    RWopsSetUp,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   746
    rwopsTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6999
diff changeset
   747
    RWopsTearDown
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
   748
};