summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2020-04-10 14:14:25 -0700
committerKarolin Seeger <kseeger@samba.org>2020-04-17 10:19:13 +0000
commit790bf2ab1988dad118c845c5f477d1f3701d0c7a (patch)
treee4d667203c77499bb0701abd570340233500b131
parent5ecac7b6dd54a4ad89b147bce816f024221d4635 (diff)
downloadsamba-790bf2ab1988dad118c845c5f477d1f3701d0c7a.tar.gz
s3: VFS: Add cmocka test for vfs_full_audit to make sure all arrays are correct.
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> (Back-ported from commit 5e987e2f40e7698de489696d795ebe26b7e75c9b) Autobuild-User(v4-12-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-12-test): Fri Apr 17 10:19:13 UTC 2020 on sn-devel-184
-rw-r--r--source3/modules/test_vfs_full_audit.c49
-rw-r--r--source3/modules/wscript_build5
-rwxr-xr-xsource3/selftest/tests.py4
3 files changed, 58 insertions, 0 deletions
diff --git a/source3/modules/test_vfs_full_audit.c b/source3/modules/test_vfs_full_audit.c
new file mode 100644
index 00000000000..4a12e466ff3
--- /dev/null
+++ b/source3/modules/test_vfs_full_audit.c
@@ -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);
+}
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index 41d8568e43a..d4c87209106 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -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',
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 6bdbb6f97a4..68ca1eac6e8 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -466,6 +466,10 @@ plantestsuite("samba3.test_nfs4_acl", "none",
[os.path.join(bindir(), "test_nfs4_acls"),
"$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")])