lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 23 Oct 2012 10:03:02 +0200
From:	<steffen.schwigon@....com>
To:	<linux-kernel@...r.kernel.org>
CC:	<ss5@...ormalist.net>, <srostedt@...hat.com>,
	<Dariusz.Filipski@...arch.com>,
	<yoshitake.kobayashi@...hiba.co.jp>, <sassmann@...hat.com>,
	<andre.przywara@....com>, <frank.arnold@....com>,
	<conny.seidel@....com>, <csd@...adcom.com>,
	Steffen Schwigon <steffen.schwigon@....com>
Subject: [PATCH 2/2] A common test subdirectory

From: Steffen Schwigon <steffen.schwigon@....com>

This commit introduces t/ as a subdirectory for placing
tests that can be run via the existing Linux tool
'prove' (available in all major Linux distributions).

Tests in there are assumed to produce TAP, the "Test
Anything Protocol" (see http://testanything.org).

A library with special utilities to write TAP tests for
Linux (inclusive KVM and Xen support) is provided in the
previous commit ('bash-test-utils'). TAP libraries are
available for many programming languages. The autotest
project already provides TAP support.

Signed-off-by: Steffen Schwigon <steffen.schwigon@....com>
---
 t/examples/basic.t |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100755 t/examples/basic.t

diff --git a/t/examples/basic.t b/t/examples/basic.t
new file mode 100755
index 0000000..d776108
--- /dev/null
+++ b/t/examples/basic.t
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+############################################################
+#
+# t/examples/basic.t
+#
+# An example test script for bash-test-utils
+#
+# Run it with:
+#
+#   $ cd $LINUX_SRC_DIR
+#   $ prove -v t/examples/basic.t
+#
+############################################################
+
+. ./tools/testing/tap/bash-test-utils
+
+uname -a | grep -q Linux  # example for ok exit code
+ok $? "we run on Linux"
+
+# require_* functions gracefully exit if requirements not met
+require_cpufeature "msr"
+require_cpufeature "fpu"
+
+# store success in variables and make complex tests
+if grep -q sse2 /proc/cpuinfo ; then
+    success=0
+else
+    success=1
+fi
+
+# ok() evaluates arg 1 with exit code shell boolean semantics
+# and creates TAP
+ok $success "SSE2 in cpuinfo"
+
+# negate_ok() reverses the success semantics of ok()
+grep -q impossible-value /proc/cpuinfo
+negate_ok $? "no impossible-value in cpuinfo"
+
+# mark tests with "# TODO" at end of description
+# for test driven development
+grep -q not-yet-implemented-detail /proc/cpuinfo
+ok $? "example that fails expectedly # TODO some todo explanation"
+
+# append key:value lines to track values
+bogomips=$(grep -i bogomips /proc/cpuinfo | head -1 | cut -d: -f2)
+append_tapdata "bogomips: $(echo $bogomips)"
+
+done_testing
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ