library.at: Run tests for Python 2 and 3.
[cascardo/ovs.git] / tests / library.at
index 0765c3f..d82113f 100644 (file)
@@ -2,35 +2,52 @@ AT_BANNER([library unit tests])
 
 AT_SETUP([test flow extractor])
 AT_CHECK([$PERL `which flowgen.pl` >/dev/null 3>flows 4>pcap])
-AT_CHECK([test-flows <flows 3<pcap], [0], [checked 247 packets, 0 errors
+AT_CHECK([ovstest test-flows flows pcap], [0], [checked 247 packets, 0 errors
 ])
 AT_CLEANUP
 
 AT_SETUP([test TCP/IP checksumming])
-AT_CHECK([test-csum], [0], [....#....#....##................................#................................#
+AT_CHECK([ovstest test-csum], [0], [....#....#....####................................#................................#
 ])
 AT_CLEANUP
 
 AT_SETUP([test hash functions])
-AT_CHECK([test-hash])
+AT_CHECK([ovstest test-hash])
 AT_CLEANUP
 
 AT_SETUP([test hash map])
-AT_CHECK([test-hmap], [0], [.........
+AT_KEYWORDS([hmap])
+AT_CHECK([ovstest test-hmap], [0], [.........
 ])
 AT_CLEANUP
 
+AT_SETUP([test hash index])
+AT_KEYWORDS([hindex])
+AT_CHECK([ovstest test-hindex], [0], [.....................
+])
+AT_CLEANUP
+
+AT_SETUP([test cuckoo hash])
+AT_KEYWORDS([cmap])
+AT_CHECK([ovstest test-cmap check 1], [0], [...
+])
+AT_CLEANUP
+
+AT_SETUP([test atomic operations])
+AT_CHECK([ovstest test-atomic])
+AT_CLEANUP
+
 AT_SETUP([test linked lists])
-AT_CHECK([test-list], [0], [..
+AT_CHECK([ovstest test-list], [0], [...
 ])
 AT_CLEANUP
 
 AT_SETUP([test packet library])
-AT_CHECK([test-packets])
+AT_CHECK([ovstest test-packets])
 AT_CLEANUP
 
 AT_SETUP([test SHA-1])
-AT_CHECK([test-sha1], [0], [.........
+AT_CHECK([ovstest test-sha1], [0], [.........
 ])
 AT_CLEANUP
 
@@ -45,11 +62,11 @@ AT_CLEANUP
 
 AT_SETUP([test byte order conversion])
 AT_KEYWORDS([byte order])
-AT_CHECK([test-byte-order])
+AT_CHECK([ovstest test-byte-order])
 AT_CLEANUP
 
 AT_SETUP([test random number generator])
-AT_CHECK([test-random], [0], [dnl
+AT_CHECK([ovstest test-random], [0], [dnl
 average=7fa2014f
 
 bit      0     1
@@ -103,40 +120,112 @@ AT_CLEANUP
 m4_foreach(
   [testname],
   [[ctz],
-   [popcount],
+   [clz],
+   [round_up_pow2],
+   [round_down_pow2],
+   [count_1bits],
    [log_2_floor],
    [bitwise_copy],
    [bitwise_zero],
    [bitwise_one],
-   [bitwise_is_all_zeros]],
+   [bitwise_is_all_zeros],
+   [ovs_scan]],
   [AT_SETUP([testname[()] function])
    AT_KEYWORDS([testname])
-   AT_CHECK([test-util testname], [0], [], [])
+   AT_CHECK([ovstest test-util testname], [0], [], [])
    AT_CLEANUP])
 
-AT_SETUP([test unix socket -- short pathname])
-AT_CHECK([test-unix-socket x])
+AT_SETUP([test unix socket, short pathname - C])
+AT_SKIP_IF([test "$IS_WIN32" = "yes"])
+AT_CHECK([ovstest test-unix-socket x])
+AT_CLEANUP
+
+dnl Unix sockets with long names are problematic because the name has to
+dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
+dnl is about 100 bytes.  On Linux, we work around this by indirecting through
+dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
+dnl for other platforms, so we skip the test there.
+AT_SETUP([test unix socket, long pathname - C])
+AT_SKIP_IF([test "$IS_WIN32" = "yes"])
+dnl Linux sockaddr_un has a 108-byte limit, so this needs to be longer.
+dnl Linux "ecryptfs" has a 143-byte limit, so we use that many bytes.
+longname=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
+
+dnl Skip the test if the directory can't be created (presumably the file
+dnl system doesn't support such long names).
+AT_CHECK([mkdir $longname || exit 77])
+
+AT_CHECK([cd $longname && ovstest test-unix-socket ../$longname/socket socket])
 AT_CLEANUP
 
+m4_define([UNIX_SOCKET_SHORT_PATHNAME_PYN],
+  [AT_SETUP([test unix socket, short pathname - $1])
+   AT_SKIP_IF([test $2 = no || test "$IS_WIN32" = "yes"])
+   AT_KEYWORDS([python unixsocket])
+   AT_CHECK([$3 $srcdir/test-unix-socket.py x])
+   AT_CLEANUP])
+
+UNIX_SOCKET_SHORT_PATHNAME_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIX_SOCKET_SHORT_PATHNAME_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
+
 dnl Unix sockets with long names are problematic because the name has to
 dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
 dnl is about 100 bytes.  On Linux, we work around this by indirecting through
 dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
 dnl for other platforms, so we skip the test there.
-AT_SETUP([test unix socket -- long pathname])
-AT_CHECK([dnl
-    case `uname` in dnl (
-      *[[lL]]inux*)
-        exit 0
-        ;; dnl (
-      *)
-        dnl Magic exit code to tell Autotest to skip this test.
-        exit 77
-        ;;
-    esac
+m4_define([UNIX_SOCKET_LONG_PATHNAME_PYN],
+  [AT_SETUP([test unix socket, long pathname - $1])
+   AT_SKIP_IF([test $2 = no || test "$IS_WIN32" = "yes"])
+   AT_KEYWORDS([python unixsocket])
+   dnl Linux sockaddr_un has a 108-byte limit, so this needs to be longer.
+   dnl Linux "ecryptfs" has a 143-byte limit, so we use that many bytes.
+   longname=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
+
+   dnl Skip the test if the directory can't be created (presumably the file
+   dnl system doesn't support such long names).
+   AT_CHECK([mkdir $longname || exit 77])
+   AT_CHECK([cd $longname && $3 $abs_srcdir/test-unix-socket.py ../$longname/socket socket])
+   AT_CLEANUP])
+
+UNIX_SOCKET_LONG_PATHNAME_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIX_SOCKET_LONG_PATHNAME_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
+
+AT_SETUP([ovs_assert])
+if test "$IS_WIN32" = "yes"; then
+  exit_status=9
+else
+  # SIGABRT + 128
+  exit_status=134
+fi
+AT_CHECK([ovstest test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert],
+  [$exit_status], [], [stderr])
+
+AT_CHECK([sed 's/\(opened log file\) .*/\1/
+s/|[[^|]]*: /|/' test-util.log], [0], [dnl
+vlog|INFO|opened log file
+util|EMER|assertion false failed in test_assert()
 ])
-dnl Linux has a 108 byte limit; this is 150 bytes long.
-mkdir 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-cd 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-AT_CHECK([test-unix-socket ../012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/socket socket])
+
+AT_CHECK([sed 's/.*: //
+1q' stderr], [0],
+  [assertion false failed in test_assert()
+])
+
+AT_CLEANUP
+
+AT_SETUP([snprintf])
+AT_CHECK([ovstest test-util snprintf])
+AT_CLEANUP
+
+AT_SETUP([test bitmap functions])
+AT_CHECK([ovstest test-bitmap check], [0], [..
+])
+AT_CLEANUP
+
+AT_SETUP([use of public headers])
+AT_CHECK([test-lib], [0], [])
+AT_CLEANUP
+
+AT_SETUP([test ofpbuf module])
+AT_CHECK([ovstest test-ofpbuf], [0], [])
 AT_CLEANUP