From f8456ed66509ccd8c54768600e44290771819222 Mon Sep 17 00:00:00 2001 From: Mark Benvenuto Date: Mon, 26 Jan 2015 16:01:04 -0500 Subject: Add support for running most C Examples via scons command line --- SConstruct | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 6 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 7d961126c34..cdfcca0fa01 100644 --- a/SConstruct +++ b/SConstruct @@ -1,7 +1,10 @@ # -*- mode: python; -*- import re import os +import shutil +import subprocess import sys +import tempfile import textwrap import distutils.sysconfig @@ -217,6 +220,8 @@ wtdll = env.SharedLibrary( env.Depends(wtdll, [filelistfile, version_file]) +Default(wtlib, wtdll) + wtbin = env.Program("wt", [ "src/utilities/util_backup.c", "src/utilities/util_cpyright.c", @@ -241,6 +246,8 @@ wtbin = env.Program("wt", [ "src/utilities/util_write.c"], LIBS=[wtlib] + wtlibs) +Default(wtbin) + # Python SWIG wrapper for WiredTiger if GetOption("lang-python"): # Check that this version of python is 64-bit @@ -271,13 +278,16 @@ if GetOption("lang-python"): swiginstall = pythonEnv.Install('lang/python/wiredtiger/', swiglib) + Default(swiginstall, copySwig) + # Shim library of functions to emulate POSIX on Windows shim = env.Library("window_shim", ["test/windows/windows_shim.c"]) -env.Program("t_bloom", +t = env.Program("t_bloom", "test/bloom/test_bloom.c", LIBS=[wtlib] + wtlibs) +Default(t) #env.Program("t_checkpoint", #["test/checkpoint/checkpointer.c", @@ -285,9 +295,10 @@ env.Program("t_bloom", #"test/checkpoint/workers.c"], #LIBS=[wtlib]) -env.Program("t_huge", +t = env.Program("t_huge", "test/huge/huge.c", LIBS=[wtlib] + wtlibs) +Default(t) #env.Program("t_fops", #["test/fops/file.c", @@ -300,7 +311,7 @@ if useBdb: benv.Append(CPPDEFINES=['BERKELEY_DB_PATH=\\"' + useBdb.replace("\\", "\\\\") + '\\"']) - benv.Program("t_format", + t = benv.Program("t_format", ["test/format/backup.c", "test/format/bdb.c", "test/format/bulk.c", @@ -312,6 +323,7 @@ if useBdb: "test/format/util.c", "test/format/wts.c"], LIBS=[wtlib, shim, "libdb61"] + wtlibs) + Default(t) #env.Program("t_thread", #["test/thread/file.c", @@ -324,13 +336,14 @@ if useBdb: #["test/salvage/salvage.c"], #LIBS=[wtlib]) -env.Program("wtperf", [ +t = env.Program("wtperf", [ "bench/wtperf/config.c", "bench/wtperf/misc.c", "bench/wtperf/track.c", "bench/wtperf/wtperf.c", ], LIBS=[wtlib, shim] + wtlibs) +Default(t) examples = [ "ex_access", @@ -352,11 +365,46 @@ examples = [ "ex_thread", ] +# WiredTiger Smoke Test suppor +# Runs each test in a custom temporary directory +# +def run_smoke_test(x): + print "Running Smoke Test: " + x + + # Make temp dir + temp_dir = tempfile.mkdtemp(prefix="wt_home") + + try: + # Set WT_HOME environment variable for test + os.environ["WIREDTIGER_HOME"] = temp_dir + + # Run the test + ret = subprocess.call(x); + if( ret != 0): + sys.stderr.write("Bad exit code %d\n" % (ret)) + raise Exception() + + finally: + # Clean directory + # + shutil.rmtree(temp_dir) + +def builder_smoke_test(target, source, env): + run_smoke_test(source[0].abspath) + return None + +env.Append(BUILDERS={'SmokeTest' : Builder(action = builder_smoke_test)}) + for ex in examples: if(ex in ['ex_all', 'ex_async', 'ex_thread']): - env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtlib, shim] + wtlibs) + exp = env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtlib, shim] + wtlibs) + Default(exp) + env.Alias("check", env.SmokeTest(exp)) else: - env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtdll[1]] + wtlibs) + exp = env.Program(ex, "examples/c/" + ex + ".c", LIBS=[wtdll[1]] + wtlibs) + Default(exp) + if not ex == 'ex_log': + env.Alias("check", env.SmokeTest(exp)) # Install Target # -- cgit v1.2.1