summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-06 14:32:44 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-06 14:32:44 +0000
commit7f29141f5069d02843468785a54543a2f6d9260a (patch)
tree18a60e0aa3081bcb49156782f4c30576679cdc52 /test
downloadlibdom-7f29141f5069d02843468785a54543a2f6d9260a.tar.gz
libdom-7f29141f5069d02843468785a54543a2f6d9260a.tar.bz2
Import DOM library.
This is mainly stub functions atm (and is missing a number of key interfaces). svn path=/trunk/dom/; revision=3384
Diffstat (limited to 'test')
-rw-r--r--test/INDEX4
-rw-r--r--test/Makefile60
-rw-r--r--test/testrunner.pl147
3 files changed, 211 insertions, 0 deletions
diff --git a/test/INDEX b/test/INDEX
new file mode 100644
index 0000000..a1b7297
--- /dev/null
+++ b/test/INDEX
@@ -0,0 +1,4 @@
+# Index for libdom testcases
+#
+# Test Description DataDir
+
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..d9bb137
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,60 @@
+# Makefile for Hubbub testcases
+#
+# Toolchain is exported by top-level makefile
+#
+# Top-level makefile also exports the following variables:
+#
+# COMPONENT Name of component
+# EXPORT Absolute path of export directory
+# TOP Absolute path of source tree root
+#
+# The top-level makefile requires the following targets to exist:
+#
+# clean Clean source tree
+# debug Create a debug binary
+# distclean Fully clean source tree, back to pristine condition
+# export Export distributable components to ${EXPORT}
+# release Create a release binary
+# setup Perform any setup required prior to compilation
+# test Execute any test cases
+
+# Extend toolchain settings
+CFLAGS += -I${TOP}/src/ -I$(CURDIR)
+
+# Release output
+RELEASE =
+
+# Debug output
+DEBUG =
+
+# Objects
+OBJS =
+
+.PHONY: clean debug export release setup test
+
+# Targets
+release:
+
+debug:
+
+clean:
+ifneq (${OBJS}, )
+ -@${RM} ${RMFLAGS} $(addsuffix ${EXEEXT}, $(OBJS))
+endif
+
+distclean:
+ -@${RM} ${RMFLAGS} log
+
+setup:
+
+export:
+
+test: $(OBJS)
+ @${PERL} testrunner.pl ${EXEEXT}
+
+# Pattern rules
+%: %.c
+ @${ECHO} ${ECHOFLAGS} "==> $<"
+ @${CC} -c -g ${CFLAGS} -o $@.o $<
+ @${LD} -g -o $@ $@.o ${LDFLAGS} -ldom-debug
+ @${RM} ${RMFLAGS} $@.o
diff --git a/test/testrunner.pl b/test/testrunner.pl
new file mode 100644
index 0000000..00c54e7
--- /dev/null
+++ b/test/testrunner.pl
@@ -0,0 +1,147 @@
+#!/bin/perl
+#
+# Testcase runner for libhubbub
+#
+# Usage: testrunner <executable extension>
+#
+# Operates upon INDEX files described in the README.
+# Locates and executes testcases, feeding data files to programs
+# as appropriate.
+# Logs testcase output to file.
+# Aborts test sequence on detection of error.
+#
+
+use warnings;
+use strict;
+use File::Spec;
+use IPC::Open3;
+
+# Get EXE extension (if any)
+my $exeext = "";
+$exeext = shift @ARGV if (@ARGV > 0);
+
+# Open log file and /dev/null
+open(LOG, ">log") or die "Failed opening test log";
+open(NULL, "+<", File::Spec->devnull) or die "Failed opening /dev/null";
+
+# Open testcase index
+open(TINDEX, "<INDEX") or die "Failed opening test INDEX";
+
+# Parse testcase index, looking for testcases
+while (my $line = <TINDEX>) {
+ next if ($line =~ /^(#.*)?$/);
+
+ # Found one; decompose
+ (my $test, my $desc, my $data) = split /\t+/, $line;
+
+ # Strip whitespace
+ $test =~ s/^\s+|\s+$//g;
+ $desc =~ s/^\s+|\s+$//g;
+ $data =~ s/^\s+|\s+$//g if ($data);
+
+ # Append EXE extension to binary name
+ $test = $test . $exeext;
+
+ print "Test: $desc\n";
+
+ my $pid;
+
+ if ($data) {
+ # Testcase has external data files
+
+ # Open datafile index
+ open(DINDEX, "<./data/$data/INDEX") or
+ die "Failed opening ./data/$data/INDEX";
+
+ # Parse datafile index, looking for datafiles
+ while (my $dentry = <DINDEX>) {
+ next if ($dentry =~ /^(#.*)?$/);
+
+ # Found one; decompose
+ (my $dtest, my $ddesc) = split /\t+/, $dentry;
+
+ # Strip whitespace
+ $dtest =~ s/^\s+|\s+$//g;
+ $ddesc =~ s/^\s+|\s+$//g;
+
+ print LOG "Running ./$test ./data/Aliases " .
+ "./data/$data/$dtest\n";
+
+ # Make message fit on an 80 column terminal
+ my $msg = " ==> $test [$data/$dtest]";
+ $msg = $msg . "." x (80 - length($msg) - 8);
+
+ print $msg;
+
+ # Run testcase
+ $pid = open3("&<NULL", \*OUT, ">&NULL",
+ "./$test", "./data/Aliases",
+ "./data/$data/$dtest");
+
+ my $last;
+
+ # Marshal testcase output to log file
+ while (my $output = <OUT>) {
+ print LOG " $output";
+ $last = $output;
+ }
+
+ # Wait for child to finish
+ waitpid($pid, 0);
+
+ print substr($last, 0, 4) . "\n";
+
+ # Bail, noisily, on failure
+ if (substr($last, 0, 4) eq "FAIL") {
+ print "\n\nFailure detected: " .
+ "consult log file\n\n\n";
+
+ exit(1);
+ }
+ }
+
+ close(DINDEX);
+ } else {
+ # Testcase has no external data files
+ print LOG "Running ./$test ./data/Aliases\n";
+
+ # Make message fit on an 80 column terminal
+ my $msg = " ==> $test";
+ $msg = $msg . "." x (80 - length($msg) - 8);
+
+ print $msg;
+
+ # Run testcase
+ $pid = open3("&<NULL", \*OUT, "&>NULL",
+ "./$test", "./data/Aliases");
+
+ my $last;
+
+ # Marshal testcase output to log file
+ while (my $output = <OUT>) {
+ print LOG " $output";
+ $last = $output;
+ }
+
+ # Wait for child to finish
+ waitpid($pid, 0);
+
+ print substr($last, 0, 4) . "\n";
+
+ # Bail, noisily, on failure
+ if (substr($last, 0, 4) eq "FAIL") {
+ print "\n\nFailure detected: " .
+ "consult log file\n\n\n";
+
+ exit(1);
+ }
+ }
+
+ print "\n";
+}
+
+# Clean up
+close(TINDEX);
+
+close(NULL);
+close(LOG);