]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture/smb2: make use of torture_assert_*_equal_goto() in streams.c
authorStefan Metzmacher <metze@samba.org>
Mon, 8 Jul 2024 07:05:49 +0000 (09:05 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 29 Aug 2024 18:25:28 +0000 (18:25 +0000)
We should fail immediately...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15656

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/torture/smb2/streams.c

index f18048f7762aee2d33f51918d4093d41bb9353b9..640976d490f7da8857a2d7e2407094ab53c0b927 100644 (file)
 
 #define DNAME "teststreams"
 
-#define CHECK_STATUS(status, correct) do { \
-       if (!NT_STATUS_EQUAL(status, correct)) { \
-               torture_result(tctx, TORTURE_FAIL, \
-                   "(%s) Incorrect status %s - should be %s\n", \
-                   __location__, nt_errstr(status), nt_errstr(correct)); \
-               ret = false; \
-               goto done; \
-       }} while (0)
-
-#define CHECK_VALUE(v, correct) do { \
-       if ((v) != (correct)) { \
-               torture_result(tctx, TORTURE_FAIL, \
-                   "(%s) Incorrect value %s=%d - should be %d\n", \
-                   __location__, #v, (int)v, (int)correct); \
-               ret = false; \
-       }} while (0)
-
-#define CHECK_NTTIME(v, correct) do { \
-       if ((v) != (correct)) { \
-               torture_result(tctx, TORTURE_FAIL, \
-                   "(%s) Incorrect value %s=%llu - should be %llu\n", \
-                   __location__, #v, (unsigned long long)v, \
-                   (unsigned long long)correct); \
-               ret = false; \
-       }} while (0)
-
-#define CHECK_STR(v, correct) do { \
-       bool ok; \
-       if ((v) && !(correct)) { \
-               ok = false; \
-       } else if (!(v) && (correct)) { \
-               ok = false; \
-       } else if (!(v) && !(correct)) { \
-               ok = true; \
-       } else if (strcmp((v), (correct)) == 0) { \
-               ok = true; \
-       } else { \
-               ok = false; \
-       } \
-       if (!ok) { \
-               torture_result(tctx, TORTURE_FAIL, \
-                              "(%s) Incorrect value %s='%s' - "        \
-                              "should be '%s'\n",                      \
-                              __location__, #v, (v)?(v):"NULL",        \
-                              (correct)?(correct):"NULL");             \
-               ret = false;                                            \
-       }} while (0)
+#define CHECK_STATUS(status, correct) \
+       torture_assert_ntstatus_equal_goto(tctx, status, correct, ret, done, "CHECK_STATUS")
 
+#define CHECK_VALUE(v, correct) \
+       torture_assert_u64_equal_goto(tctx, v, correct, ret, done, "CHECK_VALUE")
+
+#define CHECK_NTTIME(v, correct) \
+       torture_assert_nttime_equal_goto(tctx, v, correct, ret, done, "CHECK_NTTIME")
+
+#define CHECK_STR(v, correct) \
+       torture_assert_str_equal_goto(tctx, v, correct, ret, done, "CHECK_STR")
 
 static int qsort_string(char * const *s1, char * const *s2)
 {
@@ -1349,22 +1312,12 @@ done:
        sfinfo.generic.level = RAW_SFILEINFO_ ## call; \
        sfinfo.generic.in.file.handle = h1; \
        status = smb2_setinfo_file(tree, &sfinfo); \
-       if (!NT_STATUS_EQUAL(status, rightstatus)) { \
-               torture_result(tctx, TORTURE_FAIL,                      \
-                              "(%s) %s - %s (should be %s)\n",         \
-                              __location__, #call,                     \
-                              nt_errstr(status), nt_errstr(rightstatus)); \
-               ret = false;                                            \
-       } \
+       torture_assert_ntstatus_equal_goto(tctx, status, rightstatus, ret, done, #call); \
        finfo1.generic.level = RAW_FILEINFO_ALL_INFORMATION; \
        finfo1.generic.in.file.handle = h1; \
        status2 = smb2_getinfo_file(tree, tctx, &finfo1); \
-       if (!NT_STATUS_IS_OK(status2)) { \
-               torture_result(tctx, TORTURE_FAIL,           \
-                              "(%s) %s pathinfo - %s\n",    \
-                              __location__, #call, nt_errstr(status)); \
-               ret = false; \
-       }} while (0)
+       torture_assert_ntstatus_ok_goto(tctx, status2, ret, done, "ALL_INFO"); \
+} while (0)
 
 /*
   test stream renames