public: add test to check that pair Q_buildos and Q_buildarch return expected (for this build) data

This commit is contained in:
Alibek Omarov
2024-11-12 21:24:48 +03:00
parent 4342689e73
commit a6592e7776
2 changed files with 35 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#include <stdlib.h>
#include "build.h"
#include "buildenums.h"
#include "crtlib.h"
#ifndef VALIDATE_TARGET
#error
#endif
int main( void )
{
string buf;
if( Q_snprintf( buf, sizeof( buf ), "%s-%s", Q_buildos( ), Q_buildarch( )) < 0 )
return 1;
if( Q_strcmp( buf, VALIDATE_TARGET ) != 0 )
return 2;
return EXIT_SUCCESS;
}
+14
View File
@@ -56,11 +56,16 @@ def export_define(conf, define, value=1):
def simple_check(conf, fragment, msg, mandatory=False, **kw):
return conf.check_cc(fragment=fragment, msg='Checking for %s' % msg, mandatory=mandatory, **kw)
def options(opt):
opt.add_option('--validate-target', action='store', dest='VALIDATE_TARGET', default=None,
help='development option, needs --enable-tests flag')
def configure(conf):
# private to libpublic
conf.load('gitversion')
conf.define('XASH_BUILD_COMMIT', conf.env.GIT_VERSION if conf.env.GIT_VERSION else 'unknown-commit')
conf.define('XASH_BUILD_BRANCH', conf.env.GIT_BRANCH if conf.env.GIT_BRANCH else 'unknown-branch')
conf.env.VALIDATE_TARGET = conf.options.VALIDATE_TARGET
# need to expose it for everyone using libpublic headers
conf.env.EXPORT_DEFINES_LIST = []
@@ -116,6 +121,15 @@ def build(bld):
subsystem = bld.env.MSVC_SUBSYSTEM)
if bld.env.TESTS:
if bld.env.VALIDATE_TARGET:
bld.program(features = 'test',
source = 'tests/test_validate_target.c',
target = 'validate_target',
use = 'public',
defines = 'VALIDATE_TARGET="%s"' % bld.env.VALIDATE_TARGET,
subsystem = bld.env.CONSOLE_SUBSYSTEM,
install_path = None)
tests = {
'strings': 'tests/test_strings.c',
'build': 'tests/test_build.c',