I've recently been working on setting up an automated build and test
of the Wget source on Travis-CI. This threw a couple of issues that
I've since debugged.

As of now, there is an automated build and test of Wget on every
commit pushed to the "travis" branch on my personal repository of Wget
on Github[1]. I have attached two patches here which came to light due
to the Travis tests.
1. The valgrind suppressions file for SSL tests was not included in
the MAKE_DIST variable causing distcheck to fail.
2. Fix wrong logic in Test-ftp-pasv-no-support.px.

Also, I've attached a patch for including the .travis.yml file and a
script for compiling and running tests on the Travis container. If
someone here has experience setting up tests on Travis, kindly to
review the patch to see if something can be improved.

Currently, the tests on Travis fail since the valgrind tests are
failing. This is interesting because on my Arch Linux machine with
valgrind 3.11, all the tests pass. But on the Ubuntu Precise container
with Valgrind 3.8, 6 of the Perl tests fail due to "An unconditional
jump based on uninitialized values". I can reproduce these on a
virtual machine running Ubuntu Precise, but am unable to do so on my
local Arch Linux machine. The log file for the latest run as of this
email is: https://s3.amazonaws.com/archive.travis-ci.org/jobs/84697418/log.txt

If this looks good, I'd like to set up Travis to run against a new
commit push to Wget's repository on Savannah and add a couple more
test cases.


[1]: https://github.com/darnir/wget

-- 
Thanking You,
Darshit Shah
From c1b8ee4222cebe09588aaeee63fbdfc3c5c32c0d Mon Sep 17 00:00:00 2001
From: Darshit Shah <[email protected]>
Date: Sun, 11 Oct 2015 00:37:01 +0530
Subject: [PATCH 2/2] Fix Test-ftp-pasv-not-supported.px

    * tests/Test-ftp-pasv-not-supported.px: We do *NOT* expect any
    downloaded files. Also, do not negate the Test response.

    The test originally expected a downloaded file, but this is not
    true. As a result, the test would fail and return exit code 1. This
    was presumably the reason why the test result was negated before
    returning to the shell. Fix this issue, so that the test runs
    correctly without any hacks.
---
 tests/Test-ftp-pasv-not-supported.px | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/tests/Test-ftp-pasv-not-supported.px b/tests/Test-ftp-pasv-not-supported.px
index 97d0610..1a473ad 100755
--- a/tests/Test-ftp-pasv-not-supported.px
+++ b/tests/Test-ftp-pasv-not-supported.px
@@ -41,11 +41,7 @@ my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:{{port}}/afile.txt";;
 
 my $expected_error_code = 8;
 
-my %expected_downloaded_files = (
-    'afile.txt' => {
-        content => $afile,
-    },
-);
+my %expected_downloaded_files = ();
 
 ###############################################################################
 
@@ -55,6 +51,6 @@ my $the_test = FTPTest->new (
                              cmdline => $cmdline,
                              errcode => $expected_error_code,
                              output => \%expected_downloaded_files);
-exit !$the_test->run();
+exit $the_test->run();
 
 # vim: et ts=4 sw=4
-- 
2.6.1

From e77625cd996b51d6eeb8833ef69a64fb453e48eb Mon Sep 17 00:00:00 2001
From: Darshit Shah <[email protected]>
Date: Mon, 28 Sep 2015 20:53:48 +0530
Subject: [PATCH 1/2] Fix make distcheck failures in Perl SSL Tests

    * tests/Makefile.am: Add valgrind-suppressions-ssl to EXTRA_DIST
    * tests/Test-proxied-https-auth-keepalive.px: Find valgrind in
    correct path during make distcheck
    * tests/Test-proxied-https-auth.px: Same
---
 tests/Makefile.am                          | 2 +-
 tests/Test-proxied-https-auth-keepalive.px | 7 ++++++-
 tests/Test-proxied-https-auth.px           | 7 ++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index daf162f..d3bb6a5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -132,7 +132,7 @@ PX_TESTS = \
 
 EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
              WgetTests.pm WgetFeature.pm WgetFeature.cfg $(PX_TESTS) \
-             certs valgrind-suppressions
+             certs valgrind-suppressions valgrind-suppressions-ssl
 
 check_PROGRAMS = unit-tests
 unit_tests_SOURCES =
diff --git a/tests/Test-proxied-https-auth-keepalive.px b/tests/Test-proxied-https-auth-keepalive.px
index e407f31..ab90839 100755
--- a/tests/Test-proxied-https-auth-keepalive.px
+++ b/tests/Test-proxied-https-auth-keepalive.px
@@ -146,11 +146,16 @@ my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee"
     . " https://no.such.domain/needs-auth.txt";;
 $cmdline =~ s/{{port}}/$SOCKET->sockport()/e;
 
+our $VALGRIND_SUPP_FILE = $srcdir . '/valgrind-suppressions-ssl';
+
 my $valgrind = $ENV{VALGRIND_TESTS};
 if (!defined $valgrind || $valgrind eq "" || $valgrind == 0) {
     # Valgrind not requested - leave $cmdline as it is
 } elsif ($valgrind == 1) {
-    $cmdline = "valgrind --suppressions=valgrind-suppressions-ssl --error-exitcode=301 --leak-check=yes --track-origins=yes " . $cmdline;
+    $cmdline =
+      'valgrind --suppressions=' . $VALGRIND_SUPP_FILE
+      . ' --error-exitcode=301 --leak-check=yes --track-origins=yes '
+      . $cmdline;
 } else {
     $cmdline = $valgrind . " " . $cmdline;
 }
diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px
index 1daefe8..bb80893 100755
--- a/tests/Test-proxied-https-auth.px
+++ b/tests/Test-proxied-https-auth.px
@@ -145,11 +145,16 @@ my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee"
     . " https://no.such.domain/needs-auth.txt";;
 $cmdline =~ s/{{port}}/$SOCKET->sockport()/e;
 
+our $VALGRIND_SUPP_FILE = $srcdir . '/valgrind-suppressions-ssl';
+
 my $valgrind = $ENV{VALGRIND_TESTS};
 if (!defined $valgrind || $valgrind eq "" || $valgrind == 0) {
     # Valgrind not requested - leave $cmdline as it is
 } elsif ($valgrind == 1) {
-    $cmdline = "valgrind  --suppressions=valgrind-suppressions-ssl --error-exitcode=301 --leak-check=yes --track-origins=yes " . $cmdline;
+    $cmdline =
+      'valgrind --suppressions=' . $VALGRIND_SUPP_FILE
+      . ' --error-exitcode=301 --leak-check=yes --track-origins=yes '
+      . $cmdline;
 } else {
     $cmdline = $valgrind . " " . $cmdline;
 }
-- 
2.6.1

From 94e7035d20e159d6a630ea05f58d88fa9e32611d Mon Sep 17 00:00:00 2001
From: Darshit Shah <[email protected]>
Date: Sun, 11 Oct 2015 01:16:14 +0530
Subject: [PATCH] Add .travis.yml file and script for Travis-CI

    * .travis.yml: New file. Configuration file for Travis
    * contrib/travis-ci: New Bash script to compile and run tests on
    Travis.
---
 .travis.yml       | 35 +++++++++++++++++++++++++++++++++++
 contrib/travis-ci | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
 create mode 100644 .travis.yml
 create mode 100755 contrib/travis-ci

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..c496406
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,35 @@
+sudo: no
+
+language: c
+
+compiler:
+    - gcc
+    - clang
+
+addons:
+    apt:
+        packages:
+            - automake
+            - autoconf
+            - autopoint
+            - flex
+            - texinfo
+            - pkg-config
+            - libgnutls-dev
+            - libssl-dev
+            - make
+            - libhttp-daemon-perl
+            - libio-socket-ssl-perl
+            - libidn11-dev
+            - gettext
+            - texlive
+            - python3
+            - valgrind
+
+before_script:
+    - export CFLAGS="-O2 -Wall -Wextra"
+    - export PERLLIB=$PERLLIB:../../tests
+    - export PERL5LIB=$PERL5LIB:../../tests
+
+script:
+    - ./contrib/travis-ci
diff --git a/contrib/travis-ci b/contrib/travis-ci
new file mode 100755
index 0000000..585c135
--- /dev/null
+++ b/contrib/travis-ci
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Set a stricter bash mode
+set -e
+set -u
+
+# Get the number of cores on the machine. We can use any many to run tests in
+# parallel.
+CORES=$(grep -c ^processor /proc/cpuinfo 2> /dev/null || echo 0)
+if [ $CORES -lt 1 ]; then CORES=1; fi
+
+# Run `make distclean`. This is currently not required and results in an error
+# on Travis. But eventually with cached directories, this may be useful.
+echo "Running: make distclean"
+make distclean > /dev/null || true
+echo
+
+# Define a large number of Warning flags for the compiler. Hopefully, someone
+# will sit and analyze the output to clean the warnings from the codebase.
+CFLAGS="-std=c89 -pedantic -O2 -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wwrite-strings -Wshadow -Wformat -Wformat-security -Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition"
+
+# A cachefile for ./configure. I'm not sure if this is any useful.
+CACHEFILE=$PWD/config_check.cache
+
+# measure time consumed and print it at the end of the script
+START=$(date +%s.%N)
+
+echo "Running: ./bootstrap"
+./bootstrap
+echo
+
+# the compiler changed, so we have to remove the cache file here
+rm -f "$CACHEFILE"
+
+for options in "" "--with-ssl=openssl"; do
+  export DISTCHECK_CONFIGURE_FLAGS="-C --cache-file=$CACHEFILE $options"
+  echo "  ./configure $DISTCHECK_CONFIGURE_FLAGS CFLAGS=\"$CFLAGS\""
+  ./configure $DISTCHECK_CONFIGURE_FLAGS CFLAGS="$CFLAGS"
+
+  for xLCALL in C tr_TR.utf8; do
+    export TESTS_ENVIRONMENT="LC_ALL=$xLCALL VALGRIND_TESTS=1"
+    echo "    TESTS_ENVIRONMENT=\"$TESTS_ENVIRONMENT\" make distcheck CFLAGS=$CFLAGS -j$CORES"
+    make distcheck CFLAGS="$CFLAGS" -j$CORES
+  done
+done
+
+END=$(date +%s.%N)
+echo "Duration: $(echo "$END - $START" | bc)"
-- 
2.6.1

Reply via email to