svn commit: r348000 - head/tests/sys/sys

Edward Tomasz Napierala trasz at FreeBSD.org
Mon May 20 18:35:24 UTC 2019


Author: trasz
Date: Mon May 20 18:35:23 2019
New Revision: 348000
URL: https://svnweb.freebsd.org/changeset/base/348000

Log:
  Improve tree(3) tests by using ATF_REQUIRE where applicable.
  
  MFC after:	2 weeks
  Sponsored by:	Klara Inc.

Modified:
  head/tests/sys/sys/rb_test.c
  head/tests/sys/sys/splay_test.c

Modified: head/tests/sys/sys/rb_test.c
==============================================================================
--- head/tests/sys/sys/rb_test.c	Mon May 20 18:07:45 2019	(r347999)
+++ head/tests/sys/sys/rb_test.c	Mon May 20 18:35:23 2019	(r348000)
@@ -69,7 +69,7 @@ ATF_TC_BODY(rb_test, tc)
 
 	for (i = 0; i < ITER; i++) {
 		tmp = malloc(sizeof(struct node));
-		ATF_CHECK_MSG(tmp != NULL, "malloc failed");
+		ATF_REQUIRE_MSG(tmp != NULL, "malloc failed");
 		do {
 			tmp->key = arc4random_uniform(MAX-MIN);
 			tmp->key += MIN;
@@ -82,20 +82,22 @@ ATF_TC_BODY(rb_test, tc)
 			if (tmp->key < min)
 				min = tmp->key;
 		}
-		ATF_CHECK_EQ(NULL, RB_INSERT(tree, &root, tmp));
+		ATF_REQUIRE_EQ(NULL, RB_INSERT(tree, &root, tmp));
 	}
 
 	ins = RB_MIN(tree, &root);
+	ATF_REQUIRE_MSG(ins != NULL, "RB_MIN error");
 	ATF_CHECK_EQ(min, ins->key);
 	tmp = ins;
 	ins = RB_MAX(tree, &root);
+	ATF_REQUIRE_MSG(ins != NULL, "RB_MAX error");
 	ATF_CHECK_EQ(max, ins->key);
 
 	ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
 
 	for (i = 0; i < ITER - 1; i++) {
 		tmp = RB_ROOT(&root);
-		ATF_CHECK_MSG(tmp != NULL, "RB_ROOT error");
+		ATF_REQUIRE_MSG(tmp != NULL, "RB_ROOT error");
 		ATF_CHECK_EQ(tmp, RB_REMOVE(tree, &root, tmp));
 		free(tmp);
 	}

Modified: head/tests/sys/sys/splay_test.c
==============================================================================
--- head/tests/sys/sys/splay_test.c	Mon May 20 18:07:45 2019	(r347999)
+++ head/tests/sys/sys/splay_test.c	Mon May 20 18:35:23 2019	(r348000)
@@ -69,7 +69,7 @@ ATF_TC_BODY(splay_test, tc)
 
 	for (i = 0; i < ITER; i++) {
 		tmp = malloc(sizeof(struct node));
-		ATF_CHECK_MSG(tmp != NULL, "malloc failed");
+		ATF_REQUIRE_MSG(tmp != NULL, "malloc failed");
 		do {
 			tmp->key = arc4random_uniform(MAX-MIN);
 			tmp->key += MIN;
@@ -82,20 +82,22 @@ ATF_TC_BODY(splay_test, tc)
 			if (tmp->key < min)
 				min = tmp->key;
 		}
-		ATF_CHECK_EQ(NULL, SPLAY_INSERT(tree, &root, tmp));
+		ATF_REQUIRE_EQ(NULL, SPLAY_INSERT(tree, &root, tmp));
 	}
 
 	ins = SPLAY_MIN(tree, &root);
+	ATF_REQUIRE_MSG(ins != NULL, "SPLAY_MIN error");
 	ATF_CHECK_EQ(min, ins->key);
 	tmp = ins;
 	ins = SPLAY_MAX(tree, &root);
+	ATF_REQUIRE_MSG(ins != NULL, "SPLAY_MAX error");
 	ATF_CHECK_EQ(max, ins->key);
 
 	ATF_CHECK_EQ(tmp, SPLAY_REMOVE(tree, &root, tmp));
 
 	for (i = 0; i < ITER - 1; i++) {
 		tmp = SPLAY_ROOT(&root);
-		ATF_CHECK_MSG(tmp != NULL, "SPLAY_ROOT error");
+		ATF_REQUIRE_MSG(tmp != NULL, "SPLAY_ROOT error");
 		ATF_CHECK_EQ(tmp, SPLAY_REMOVE(tree, &root, tmp));
 		free(tmp);
 	}


More information about the svn-src-all mailing list