]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tevent: add support for cmocka unit tests
authorPavel Březina <pbrezina@redhat.com>
Thu, 3 Jun 2021 11:05:46 +0000 (13:05 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 7 Jul 2021 05:07:30 +0000 (05:07 +0000)
This adds a placeholder for new cmocka tests for tevent. Tests
are added in individual commits.

Signed-off-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/tevent/wscript

index 93af416f583c31dc6874f13ba4fb0667c00dddd5..bc28f7cbb46d1ef0a1756a7cde71171bb1feb149 100644 (file)
@@ -15,9 +15,12 @@ out = 'bin'
 
 import wafsamba
 from wafsamba import samba_dist, samba_utils
-from waflib import Options, Logs, Context
+from waflib import Options, Logs, Context, Errors
 
-samba_dist.DIST_DIRS('lib/tevent:. lib/replace:lib/replace lib/talloc:lib/talloc buildtools:buildtools third_party/waf:third_party/waf')
+samba_dist.DIST_DIRS('''lib/tevent:. lib/replace:lib/replace
+                        lib/talloc:lib/talloc buildtools:buildtools
+                        third_party/cmocka:third_party/cmocka
+                        third_party/waf:third_party/waf''')
 
 def options(opt):
     opt.BUILTIN_DEFAULT('replace')
@@ -30,6 +33,14 @@ def configure(conf):
     conf.RECURSE('lib/replace')
     conf.RECURSE('lib/talloc')
 
+    if conf.CHECK_FOR_THIRD_PARTY():
+        conf.RECURSE('third_party/cmocka')
+    else:
+        if not conf.CHECK_CMOCKA():
+            raise Errors.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
+        else:
+            conf.define('USING_SYSTEM_CMOCKA', 1)
+
     conf.env.standalone_tevent = conf.IN_LAUNCH_DIR()
 
     if not conf.env.standalone_tevent:
@@ -71,6 +82,9 @@ def build(bld):
     bld.RECURSE('lib/replace')
     bld.RECURSE('lib/talloc')
 
+    if bld.CHECK_FOR_THIRD_PARTY():
+        bld.RECURSE('third_party/cmocka')
+
     SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
              tevent_queue.c tevent_req.c tevent_wrapper.c
              tevent_poll.c tevent_threads.c
@@ -130,8 +144,17 @@ def test(ctx):
     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
 
     pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
-    sys.exit(pyret)
 
+    unit_test_ret = 0
+    unit_tests = [
+
+    ]
+
+    for unit_test in unit_tests:
+        unit_test_cmd = os.path.join(Context.g_module.out, unit_test)
+        unit_test_ret = unit_test_ret or samba_utils.RUN_COMMAND(unit_test_cmd)
+
+    sys.exit(pyret or unit_test_ret)
 
 def dist():
     '''makes a tarball for distribution'''