mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-03-10 04:31:16 +00:00
filesystem: add base test case to call ShutdownStdio without calling Init prior
This commit is contained in:
parent
a3603f497d
commit
31ae22961b
@ -1439,7 +1439,10 @@ void FS_ShutdownStdio( void )
|
|||||||
int i;
|
int i;
|
||||||
// release gamedirs
|
// release gamedirs
|
||||||
for( i = 0; i < FI.numgames; i++ )
|
for( i = 0; i < FI.numgames; i++ )
|
||||||
if( FI.games[i] ) Mem_Free( FI.games[i] );
|
{
|
||||||
|
if( FI.games[i] )
|
||||||
|
Mem_Free( FI.games[i] );
|
||||||
|
}
|
||||||
|
|
||||||
FS_ClearSearchPath(); // release all wad files too
|
FS_ClearSearchPath(); // release all wad files too
|
||||||
Mem_FreePool( &fs_mempool );
|
Mem_FreePool( &fs_mempool );
|
||||||
|
85
filesystem/tests/no-init.c
Normal file
85
filesystem/tests/no-init.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include "port.h"
|
||||||
|
#include "build.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include "filesystem.h"
|
||||||
|
#if XASH_POSIX
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#define LoadLibrary( x ) dlopen( x, RTLD_NOW )
|
||||||
|
#define GetProcAddress( x, y ) dlsym( x, y )
|
||||||
|
#define FreeLibrary( x ) dlclose( x )
|
||||||
|
#elif XASH_WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void *g_hModule;
|
||||||
|
FSAPI g_pfnGetFSAPI;
|
||||||
|
fs_api_t g_fs;
|
||||||
|
fs_globals_t *g_nullglobals;
|
||||||
|
|
||||||
|
|
||||||
|
static qboolean LoadFilesystem( void )
|
||||||
|
{
|
||||||
|
g_hModule = LoadLibrary( "filesystem_stdio." OS_LIB_EXT );
|
||||||
|
if( !g_hModule )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
g_pfnGetFSAPI = (void*)GetProcAddress( g_hModule, GET_FS_API );
|
||||||
|
if( !g_pfnGetFSAPI )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !g_pfnGetFSAPI( FS_API_VERSION, &g_fs, &g_nullglobals, NULL ))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int TestNoInit( void )
|
||||||
|
{
|
||||||
|
char nice[69];
|
||||||
|
fs_dllinfo_t dllinfo;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
// here are the APIs that shouldn't fail without calling InitStdio
|
||||||
|
g_fs.ShutdownStdio();
|
||||||
|
g_fs.ClearSearchPath();
|
||||||
|
g_fs.AllowDirectPaths( true );
|
||||||
|
g_fs.AllowDirectPaths( false );
|
||||||
|
if( g_fs.Search( "asfjkajk", 0, 0 ) != 0 )
|
||||||
|
return 0;
|
||||||
|
g_fs.SetCurrentDirectory( "asdasdasdasd" );
|
||||||
|
g_fs.FindLibrary( "kek", true, &dllinfo );
|
||||||
|
if( g_fs.Open( "afbvasvwerf", "w+", true ) != 0 )
|
||||||
|
return 0;
|
||||||
|
if( g_fs.LoadFile( "hehe", NULL, true ) != 0 )
|
||||||
|
return 0;
|
||||||
|
p = g_fs.LoadDirectFile( "hehe", NULL );
|
||||||
|
if( p ) free( p );
|
||||||
|
|
||||||
|
g_fs.FileExists( "asdcv", 0 );
|
||||||
|
g_fs.FileTime( "zxcasdfd", 0 );
|
||||||
|
g_fs.FileSize( "asdqwe", 1 );
|
||||||
|
g_fs.Rename( "cafqefv", "zvewfw" );
|
||||||
|
g_fs.SysFileExists( "zbarbgaer" );
|
||||||
|
g_fs.GetDiskPath( "aggasdfbaergba", 0 );
|
||||||
|
g_fs.GetFullDiskPath( nice, sizeof( nice ), "oh my!", true );
|
||||||
|
g_fs.Delete( "blabla" );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( void )
|
||||||
|
{
|
||||||
|
if( !LoadFilesystem() )
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if( !TestNoInit( ))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
FreeLibrary( g_hModule );
|
||||||
|
|
||||||
|
printf( "success\n" );
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
@ -37,6 +37,7 @@ def build(bld):
|
|||||||
tests = {
|
tests = {
|
||||||
'interface' : 'tests/interface.cpp',
|
'interface' : 'tests/interface.cpp',
|
||||||
'caseinsensitive' : 'tests/caseinsensitive.c',
|
'caseinsensitive' : 'tests/caseinsensitive.c',
|
||||||
|
'no-init': 'tests/no-init.c'
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in tests:
|
for i in tests:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user