]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
travis: use own logtee.c to reduce log output
authorHarald Hoyer <harald@redhat.com>
Thu, 16 Aug 2018 08:16:52 +0000 (10:16 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 16 Aug 2018 08:17:48 +0000 (10:17 +0200)
.travis.yml
Makefile
fedora-test.sh
logtee.c [new file with mode: 0644]
test/test-functions

index 1f50b6d93db41f91719796cd24e9ef75d79be7e6..5298a816da850d330cce364cd56f4799ce7d7732 100644 (file)
@@ -10,12 +10,12 @@ env:
   - IMAGE=latest  TESTS=50
   - IMAGE=latest  TESTS=70
   - IMAGE=latest  TESTS=99
-  - IMAGE=rawhide TESTS="01 02 03 04 10 11 12 13 15 17 18"
-  - IMAGE=rawhide TESTS=20
-  - IMAGE=rawhide TESTS="30 31"
-  - IMAGE=rawhide TESTS=50
-  - IMAGE=rawhide TESTS=70
-  - IMAGE=rawhide TESTS=99
+#  - IMAGE=rawhide TESTS="01 02 03 04 10 11 12 13 15 17 18"
+#  - IMAGE=rawhide TESTS=20
+#  - IMAGE=rawhide TESTS="30 31"
+#  - IMAGE=rawhide TESTS=50
+#  - IMAGE=rawhide TESTS=70
+#  - IMAGE=rawhide TESTS=99
 
 before_script:
 - docker pull fedora:$IMAGE
index 414fb33044fed13ae6583274f927fc83cec5773f..cd02dab0bf061e0f5105541cd12125eb0d3881a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,9 @@ install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h ins
 install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
        $(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS)
 
+logtee: logtee.c
+       $(CC) $(LDFLAGS) -o $@ $<
+
 dracut-install: install/dracut-install
        ln -fs $< $@
 
index e7d0f633059dfc0a97baa7bf5f3a76c32f5ceff4..af38bc33490f2a868a0a1758fc83958af8bb35f2 100755 (executable)
@@ -45,7 +45,7 @@ dnf -y install --best --allowerasing \
 
 NCPU=$(getconf _NPROCESSORS_ONLN)
 
-make -j$NCPU all syncheck rpm
+make -j$NCPU all syncheck rpm logtee
 
 cd test
 
diff --git a/logtee.c b/logtee.c
new file mode 100644 (file)
index 0000000..2f1937d
--- /dev/null
+++ b/logtee.c
@@ -0,0 +1,46 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+
+int
+main(int argc, char *argv[])
+{
+       int fd;
+       int len, slen;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s <file>\n", argv[0]);
+               exit(EXIT_FAILURE);
+       }
+
+       fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+       if (fd == -1) {
+               perror("open");
+               exit(EXIT_FAILURE);
+       }
+
+       fprintf(stderr, "Logging to %s: ", argv[1]);
+
+       do {
+               len = splice(STDIN_FILENO, NULL, fd, NULL,
+                            65536, SPLICE_F_MOVE);
+
+               if (len < 0) {
+                       if (errno == EAGAIN)
+                               continue;
+                       perror("tee");
+                       exit(EXIT_FAILURE);
+               } else
+                       if (len == 0)
+                               break;
+               fprintf(stderr, ".", len);
+       } while (1);
+       close(fd);
+       fprintf(stderr, "\n");
+       exit(EXIT_SUCCESS);
+}
+
index d6b28d20fb183f4fb59b0d525baa1f2c0db9109b..02ceafec8c9ad92bba0569be8e5ef0a7238f9b75 100644 (file)
@@ -60,7 +60,7 @@ while (($# > 0)); do
             else
                echo "TEST: $TEST_DESCRIPTION [STARTED]";
             fi
-            if ! [[ "$V" ]]; then
+            if [[ "$V" == "1" ]]; then
                (
                    test_setup && test_run
                    ret=$?
@@ -69,6 +69,19 @@ while (($# > 0)); do
                    rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
                    exit $ret
                ) </dev/null >test-${TEST_RUN_ID:+-$TEST_RUN_ID}.log 2>&1
+            elif [[ "$V" == "2" ]]; then
+                set -o pipefail
+                (
+                   test_setup && test_run
+                   ret=$?
+                   test_cleanup
+                    if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
+                        mv [[ -f "$TESTDIR"/server.log ]] ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
+                    fi
+                   rm -fr -- "$TESTDIR"
+                   rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
+                   exit $ret
+               ) </dev/null 2>&1 | $basedir/logtee test-${TEST_RUN_ID:+-$TEST_RUN_ID}.log
             else
                 set -o pipefail
                 (