[LTP] [PATCH 1/1] lib: use tst_exit() instead of exit()

Petr Vorel pvorel@suse.cz
Thu Mar 16 12:23:59 CET 2017


Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
I'm sorry for not important commit. It's more for me to understand whether
tst_exit() should be used only for normal tests, or also for lib's tests or
even in lib itself.
---
 lib/parse_opts.c                        | 2 +-
 lib/random_range.c                      | 4 ++--
 lib/tests/tst_checkpoint.c              | 2 +-
 lib/tests/tst_checkpoint_wait_timeout.c | 2 +-
 lib/tests/tst_checkpoint_wake_timeout.c | 2 +-
 lib/tests/tst_cleanup_once.c            | 2 +-
 lib/tests/tst_dataroot01.c              | 1 -
 lib/tests/tst_process_state.c           | 4 ++--
 lib/tests/tst_safe_macros.c             | 2 +-
 lib/tests/tst_strerrno.c                | 2 +-
 lib/tests/tst_strsig.c                  | 2 +-
 lib/tests/tst_tmpdir_test.c             | 2 +-
 12 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lib/parse_opts.c b/lib/parse_opts.c
index 3a879e44e..1af8e9a6e 100644
--- a/lib/parse_opts.c
+++ b/lib/parse_opts.c
@@ -618,7 +618,7 @@ int main(int argc, char **argv)
 
 	TEST_CLEANUP;
 
-	exit(0);
+	tst_exit();
 }
 
 #endif /* UNIT_TEST */
diff --git a/lib/random_range.c b/lib/random_range.c
index 510a4a1ff..c2534e0c7 100644
--- a/lib/random_range.c
+++ b/lib/random_range.c
@@ -706,7 +706,7 @@ char **argv;
 			}
 		}
 	}
-	exit(0);
+	tst_exit();
 }
 
 #endif /* end if RANDOM_BIT_UNITTEST */
@@ -886,7 +886,7 @@ char **argv;
 
 	}
 
-	exit(0);
+	tst_exit();
 }
 
 #endif
diff --git a/lib/tests/tst_checkpoint.c b/lib/tests/tst_checkpoint.c
index 2cb17a5f7..7008171db 100644
--- a/lib/tests/tst_checkpoint.c
+++ b/lib/tests/tst_checkpoint.c
@@ -55,5 +55,5 @@ int main(void)
 
 	wait(NULL);
 	tst_rmdir();
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_checkpoint_wait_timeout.c b/lib/tests/tst_checkpoint_wait_timeout.c
index c5fae670e..eb69565c2 100644
--- a/lib/tests/tst_checkpoint_wait_timeout.c
+++ b/lib/tests/tst_checkpoint_wait_timeout.c
@@ -54,5 +54,5 @@ int main(void)
 	break;
 	}
 
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_checkpoint_wake_timeout.c b/lib/tests/tst_checkpoint_wake_timeout.c
index 8af1feb18..6a71d80b6 100644
--- a/lib/tests/tst_checkpoint_wake_timeout.c
+++ b/lib/tests/tst_checkpoint_wake_timeout.c
@@ -37,5 +37,5 @@ int main(void)
 	TST_SAFE_CHECKPOINT_WAKE(tst_rmdir, 0);
 	fprintf(stderr, "Parent: checkpoint reached\n");
 
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_cleanup_once.c b/lib/tests/tst_cleanup_once.c
index 328ed7492..73ac88db1 100644
--- a/lib/tests/tst_cleanup_once.c
+++ b/lib/tests/tst_cleanup_once.c
@@ -43,5 +43,5 @@ int main(void)
 	cleanup();
 	cleanup();
 
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_dataroot01.c b/lib/tests/tst_dataroot01.c
index fab8bfea2..e4d8a3875 100644
--- a/lib/tests/tst_dataroot01.c
+++ b/lib/tests/tst_dataroot01.c
@@ -51,4 +51,3 @@ int main(void)
 
 	tst_exit();
 }
-
diff --git a/lib/tests/tst_process_state.c b/lib/tests/tst_process_state.c
index dd4f0535d..33b87c569 100644
--- a/lib/tests/tst_process_state.c
+++ b/lib/tests/tst_process_state.c
@@ -59,7 +59,7 @@ int main(void)
 
 		fprintf(stderr, "Child woken up\n");
 
-		return 0;
+		tst_exit();
 		break;
 	default:
 		/* Wait for child to sleep */
@@ -71,5 +71,5 @@ int main(void)
 	}
 
 	wait(NULL);
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_safe_macros.c b/lib/tests/tst_safe_macros.c
index b5809f40d..6a417eff5 100644
--- a/lib/tests/tst_safe_macros.c
+++ b/lib/tests/tst_safe_macros.c
@@ -36,5 +36,5 @@ int main(int argc LTP_ATTRIBUTE_UNUSED, char **argv)
 	SAFE_WRITE(NULL, 1, fd, buf, 9);
 	SAFE_PIPE(NULL, fds);
 
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_strerrno.c b/lib/tests/tst_strerrno.c
index dbee7642f..e9ad39cfd 100644
--- a/lib/tests/tst_strerrno.c
+++ b/lib/tests/tst_strerrno.c
@@ -31,5 +31,5 @@ int main(void)
 {
 	fprintf(stderr, "0 = %s\n", tst_strerrno(0));
 	fprintf(stderr, "EINVAL = %s\n", tst_strerrno(EINVAL));
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_strsig.c b/lib/tests/tst_strsig.c
index 9a5ca80aa..d0b2184f2 100644
--- a/lib/tests/tst_strsig.c
+++ b/lib/tests/tst_strsig.c
@@ -31,5 +31,5 @@ int main(void)
 {
 	fprintf(stderr, "SIGKILL = %s\n", tst_strsig(SIGKILL));
 	fprintf(stderr, "SIGALRM = %s\n", tst_strsig(SIGALRM));
-	return 0;
+	tst_exit();
 }
diff --git a/lib/tests/tst_tmpdir_test.c b/lib/tests/tst_tmpdir_test.c
index f394893a4..f58afc26a 100644
--- a/lib/tests/tst_tmpdir_test.c
+++ b/lib/tests/tst_tmpdir_test.c
@@ -80,5 +80,5 @@ int main(void)
 	else
 		printf("Test completed successfully!\n");
 
-	return 0;
+	tst_exit();
 }
-- 
2.12.0



More information about the ltp mailing list