]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
test_utils: factorize `canProg` implementations 2669/head
authorBenoit Pierre <benoit.pierre@gmail.com>
Sat, 7 Jun 2025 22:04:24 +0000 (00:04 +0200)
committerBenoit Pierre <benoit.pierre@gmail.com>
Sat, 7 Jun 2025 22:05:58 +0000 (00:05 +0200)
test_utils/test_main.c

index 1cadd2bfacc3b333a46490d48aa47ba64f4e3611..c4244e9c6bcaa8ab4cf9641f8b3bb2c7188d6d5c 100644 (file)
@@ -2548,152 +2548,52 @@ canRunCommand(const char *cmd, int *tested)
 /*
  * Can this platform run the bzip2 program?
  */
-int
-canBzip2(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("bzip2 --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Bzip2, "bzip2 --help");
 
 /*
  * Can this platform run the grzip program?
  */
-int
-canGrzip(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("grzip -V %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Grzip, "grzip -V");
 
 /*
  * Can this platform run the gzip program?
  */
-int
-canGzip(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("gzip --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Gzip, "gzip --help");
 
 /*
  * Can this platform run the lrzip program?
  */
-int
-canLrzip(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("lrzip -V %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Lrzip, "lrzip -V");
 
 /*
  * Can this platform run the lz4 program?
  */
-int
-canLz4(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("lz4 --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Lz4, "lz4 --help");
 
 /*
  * Can this platform run the zstd program?
  */
-int
-canZstd(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("zstd --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Zstd, "zstd --help");
 
 /*
  * Can this platform run the lzip program?
  */
-int
-canLzip(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("lzip --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Lzip, "lzip --help");
 
 /*
  * Can this platform run the lzma program?
  */
-int
-canLzma(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("lzma --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Lzma, "lzma --help");
 
 /*
  * Can this platform run the lzop program?
  */
-int
-canLzop(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("lzop --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Lzop, "lzop --help");
 
 /*
  * Can this platform run the xz program?
  */
-int
-canXz(void)
-{
-       static int tested = 0, value = 0;
-       if (!tested) {
-               tested = 1;
-               if (systemf("xz --help %s", redirectArgs) == 0)
-                       value = 1;
-       }
-       return (value);
-}
+CAN_RUN_FUNC(Xz, "xz --help");
 
 /*
  * Can this filesystem handle nodump flags.