s3: VFS: Add cmocka test for vfs_full_audit to make sure all arrays are correct.
authorJeremy Allison <jra@samba.org>
Fri, 10 Apr 2020 21:14:25 +0000 (14:14 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 14 Apr 2020 17:58:40 +0000 (17:58 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14343

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 14 17:58:40 UTC 2020 on sn-devel-184

source3/modules/test_vfs_full_audit.c [new file with mode: 0644]
source3/modules/wscript_build
source3/selftest/tests.py

diff --git a/source3/modules/test_vfs_full_audit.c b/source3/modules/test_vfs_full_audit.c
new file mode 100644 (file)
index 0000000..4a12e46
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  Unit test for entries in vfs_full_audit arrays.
+ *
+ *  Copyright (C) Jeremy Allison 2020
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Needed for static build to complete... */
+#include "includes.h"
+#include "smbd/smbd.h"
+NTSTATUS vfs_full_audit_init(TALLOC_CTX *ctx);
+
+#include "vfs_full_audit.c"
+#include <cmocka.h>
+
+static void test_full_audit_array(void **state)
+{
+       unsigned i;
+
+       for (i=0; i<SMB_VFS_OP_LAST; i++) {
+               assert_non_null(vfs_op_names[i].name);
+               assert_int_equal(vfs_op_names[i].type, i);
+       }
+}
+
+int main(int argc, char **argv)
+{
+       const struct CMUnitTest tests[] = {
+               cmocka_unit_test(test_full_audit_array),
+       };
+
+       cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
+
+       return cmocka_run_group_tests(tests, NULL, NULL);
+}
index 2d81357c513eb1d701fbd724446ae5b46fade3a2..1f2d2d3acb63c08297dcdae5d3f5cf9fb2b5d5b1 100644 (file)
@@ -91,6 +91,11 @@ bld.SAMBA3_MODULE('vfs_full_audit',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_full_audit'),
                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_full_audit'))
 
+bld.SAMBA3_BINARY('test_vfs_full_audit',
+                  source='test_vfs_full_audit.c',
+                  deps='smbd_base cmocka',
+                  for_selftest=True)
+
 bld.SAMBA3_MODULE('vfs_fake_perms',
                  subsystem='vfs',
                  source='vfs_fake_perms.c',
index 1ceb0a5ad5f9427149c156f2d8c22da79eab27ae..568434a208c8e5ec8e941b11e4dedd6f3e8ec2f6 100755 (executable)
@@ -506,6 +506,10 @@ plantestsuite("samba3.test_vfs_widelinks", "none",
               [os.path.join(bindir(), "test_vfs_widelinks"),
                "$SMB_CONF_PATH"])
 
+plantestsuite("samba3.test_vfs_full_audit", "none",
+              [os.path.join(bindir(), "test_vfs_full_audit"),
+               "$SMB_CONF_PATH"])
+
 plantestsuite(
     "samba3.resolvconf", "none",
     [os.path.join(samba3srcdir, "script/tests/test_resolvconf.sh")])