summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/Makefile.am9
-rw-r--r--testsuite/systemtap.examples/ChangeLog10
-rw-r--r--testsuite/systemtap.examples/examples-index-gen.pl290
-rw-r--r--testsuite/systemtap.examples/html_footer.tmpl14
-rw-r--r--testsuite/systemtap.examples/html_header.tmpl41
-rw-r--r--testsuite/systemtap.examples/systemtap.css164
-rw-r--r--testsuite/systemtap.examples/systemtapcorner.gifbin0 -> 970 bytes
-rw-r--r--testsuite/systemtap.examples/systemtaplogo.pngbin0 -> 1860 bytes
8 files changed, 527 insertions, 1 deletions
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 03c70cb6..db278139 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -32,7 +32,14 @@ EXTRA_DIST = execrc config lib systemtap \
parseok parseko semok semko transok transko buildok buildok \
systemtap.syscall systemtap.stress systemtap.string \
systemtap.pass1-4 systemtap.samples systemtap.printf \
- systemtap.maps systemtap.base
+ systemtap.maps systemtap.base \
+ systemtap.examples/examples-index-gen.pl \
+ systemtap.examples/systemtap.css \
+ systemtap.examples/systemtapcorner.gif \
+ systemtap.examples/systemtaplogo.png \
+ systemtap.examples/html_footer.tmpl \
+ systemtap.examples/html_header.tmpl
+
# $(srcdir)/These values point the test suite to the install tree, and
# are overridden by "make check" from full source/build tree
diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog
index ca2ffbdd..fa6a3aa3 100644
--- a/testsuite/systemtap.examples/ChangeLog
+++ b/testsuite/systemtap.examples/ChangeLog
@@ -1,5 +1,15 @@
2008-08-07 Mark Wielaard <mwielaard@redhat.com>
+ * examples-index-gen.pl: New file.
+ * systemtap.css: Likewise.
+ * systemtapcorner.gif: Likewise.
+ * systemtaplogo.png: Likewise.
+ * html_footer.tmpl: Likewise.
+ * html_header.tmpl: Likewise.
+ * Makefile.am (EXTRA_DIST): Add new support files.
+
+2008-08-07 Mark Wielaard <mwielaard@redhat.com>
+
* futexes.meta: Correct name: entry.
2008-08-01 William Cohen <wcohen@redhat.com>
diff --git a/testsuite/systemtap.examples/examples-index-gen.pl b/testsuite/systemtap.examples/examples-index-gen.pl
new file mode 100644
index 00000000..bc12577e
--- /dev/null
+++ b/testsuite/systemtap.examples/examples-index-gen.pl
@@ -0,0 +1,290 @@
+# Generates index files from examples .meta file info.
+# Copyright (C) 2008 Red Hat Inc.
+#
+# This file is part of systemtap, and is free software. You can
+# redistribute it and/or modify it under the terms of the GNU General
+# Public License (GPL); either version 2, or (at your option) any
+# later version.
+
+use strict;
+use warnings;
+
+use File::Copy;
+use File::Find;
+use File::Path;
+use Text::Wrap;
+
+my $inputdir;
+if ($#ARGV >= 0) {
+ $inputdir = $ARGV[0];
+} else {
+ $inputdir = ".";
+}
+
+my $outputdir;
+if ($#ARGV >= 1) {
+ $outputdir = $ARGV[1];
+} else {
+ $outputdir = $inputdir;
+}
+
+my %scripts = ();
+print "Parsing .meta files in $inputdir...\n";
+find(\&parse_meta_files, $inputdir);
+
+my $meta;
+my $subsystem;
+my %subsystems;
+my $keyword;
+my %keywords;
+
+# Adds a formatted meta entry to a given file handle as text.
+sub add_meta_txt(*;$) {
+ my($file,$meta) = @_;
+
+ print $file "$scripts{$meta}{name} - $scripts{$meta}{title}\n";
+
+ print $file "output: $scripts{$meta}{output}, ";
+ print $file "exits: $scripts{$meta}{exit}, ";
+ print $file "status: $scripts{$meta}{status}\n";
+
+ print $file "subsystem: $scripts{$meta}{subsystem}, ";
+ print $file "keywords: $scripts{$meta}{keywords}\n\n";
+
+ $Text::Wrap::columns = 72;
+ my $description = wrap(' ', ' ', $scripts{$meta}{description});
+ print $file "$description\n\n\n";
+}
+
+# Adds a formatted meta entry to a given file handle as text.
+sub add_meta_html(*;$) {
+ my($file,$meta) = @_;
+
+ my $name = $scripts{$meta}{name};
+ print $file "<li><a href=\"$name\">$name</a> ";
+ print $file "- $scripts{$meta}{title}<br>\n";
+
+ print $file "output: $scripts{$meta}{output}, ";
+ print $file "exits: $scripts{$meta}{exit}, ";
+ print $file "status: $scripts{$meta}{status}<br>\n";
+
+ print $file "subsystem: $scripts{$meta}{subsystem}, ";
+ print $file "keywords: $scripts{$meta}{keywords}<br>\n";
+
+ print $file "<p>$scripts{$meta}{description}";
+ print $file "</p></li>\n";
+}
+
+my $HEADER = "SYSTEMTAP EXAMPLES INDEX\n"
+ . "(see also subsystem-index.txt, keyword-index.txt)\n\n";
+
+my $header_tmpl = "$inputdir/html_header.tmpl";
+open(TEMPLATE, "<$header_tmpl")
+ || die "couldn't open $header_tmpl, $!";
+my $HTMLHEADER = do { local $/; <TEMPLATE> };
+close(TEMPLATE);
+my $footer_tmpl = "$inputdir/html_footer.tmpl";
+open(TEMPLATE, "<$footer_tmpl")
+ || die "couldn't open $footer_tmpl, $!";
+my $HTMLFOOTER = do { local $/; <TEMPLATE> };
+close(TEMPLATE);
+
+# Output full index and collect subsystems and keywords
+my $fullindex = "$outputdir/index.txt";
+open (FULLINDEX, ">$fullindex")
+ || die "couldn't open $fullindex: $!";
+print "Creating $fullindex...\n";
+print FULLINDEX $HEADER;
+
+my $fullhtml = "$outputdir/index.html";
+open (FULLHTML, ">$fullhtml")
+ || die "couldn't open $fullhtml: $!";
+print "Creating $fullhtml...\n";
+print FULLHTML $HTMLHEADER;
+print FULLHTML "<h2>All Examples</h2>\n";
+print FULLHTML "<ul>\n";
+
+foreach $meta (sort keys %scripts) {
+
+ add_meta_txt(\*FULLINDEX, $meta);
+ add_meta_html(\*FULLHTML, $meta);
+
+ # Collect subsystems
+ foreach $subsystem (split(/ /, $scripts{$meta}{subsystem})) {
+ if (defined $subsystems{$subsystem}) {
+ push(@{$subsystems{$subsystem}}, $meta);
+ } else {
+ $subsystems{$subsystem} = [ $meta ];
+ }
+ }
+
+ # Collect keywords
+ foreach $keyword (split(/ /, $scripts{$meta}{keywords})) {
+ if (defined $keywords{$keyword}) {
+ push(@{$keywords{$keyword}}, $meta);
+ } else {
+ $keywords{$keyword} = [ $meta ];
+ }
+ }
+}
+print FULLHTML "</ul>\n";
+print FULLHTML $HTMLFOOTER;
+close (FULLINDEX);
+close (FULLHTML);
+
+my $SUBHEADER = "SYSTEMTAP EXAMPLES INDEX BY SUBSYSTEM\n"
+ . "(see also index.txt, keyword-index.txt)\n\n";
+
+# Output subsystem index
+my $subindex = "$outputdir/subsystem-index.txt";
+open (SUBINDEX, ">$subindex")
+ || die "couldn't open $subindex: $!";
+print "Creating $subindex...\n";
+print SUBINDEX $SUBHEADER;
+
+my $subhtml = "$outputdir/subsystem-index.html";
+open (SUBHTML, ">$subhtml")
+ || die "couldn't open $subhtml: $!";
+print "Creating $subhtml...\n";
+print SUBHTML $HTMLHEADER;
+print SUBHTML "<h2>Examples by Subsystem</h2>\n";
+
+foreach $subsystem (sort keys %subsystems) {
+ print SUBINDEX "= " . (uc $subsystem) . " =\n\n";
+ print SUBHTML "<h3>" . (uc $subsystem) . "</h3>\n";
+ print SUBHTML "<ul>\n";
+
+ foreach $meta (sort @{$subsystems{$subsystem}}) {
+ add_meta_txt(\*SUBINDEX,$meta);
+ add_meta_html(\*SUBHTML,$meta);
+ }
+ print SUBHTML "</ul>\n";
+}
+print SUBHTML $HTMLFOOTER;
+close (SUBINDEX);
+close (SUBHTML);
+
+my $KEYHEADER = "SYSTEMTAP EXAMPLES INDEX BY KEYWORD\n"
+ . "(see also index.txt, subsystem-index.txt)\n\n";
+
+# Output subsystem index
+my $keyindex = "$outputdir/keyword-index.txt";
+open (KEYINDEX, ">$keyindex")
+ || die "couldn't open $keyindex: $!";
+print "Creating $keyindex...\n";
+print KEYINDEX $KEYHEADER;
+
+my $keyhtml = "$outputdir/keyword-index.html";
+open (KEYHTML, ">$keyhtml")
+ || die "couldn't open $keyhtml: $!";
+print "Creating $keyhtml...\n";
+print KEYHTML $HTMLHEADER;
+print KEYHTML "<h2>Examples by Keyword</h2>\n";
+
+foreach $keyword (sort keys %keywords) {
+ print KEYINDEX "= " . (uc $keyword) . " =\n\n";
+ print KEYHTML "<h3>" . (uc $keyword) . "</h3>\n";
+ print KEYHTML "<ul>\n";
+
+ foreach $meta (sort @{$keywords{$keyword}}) {
+ add_meta_txt(\*KEYINDEX,$meta);
+ add_meta_html(\*KEYHTML,$meta);
+ }
+ print KEYHTML "</ul>\n";
+}
+print KEYHTML $HTMLFOOTER;
+close (KEYINDEX);
+close (KEYHTML);
+
+my @supportfiles
+ = ("systemtapcorner.gif",
+ "systemtap.css",
+ "systemtaplogo.png");
+if ($inputdir ne $outputdir) {
+ my $file;
+ print "Copying support files...\n";
+ foreach $file (@supportfiles) {
+ my $orig = "$inputdir/$file";
+ my $dest = "$outputdir/$file";
+ print "Copying $file to $dest...\n";
+ copy("$orig", $dest) or die "$file cannot be copied to $dest, $!";
+ }
+}
+
+sub parse_meta_files {
+ my $file = $_;
+ my $filename = $File::Find::name;
+
+ if (-f $file && $file =~ /\.meta$/) {
+ open FILE, $file or die "couldn't open '$file': $!\n";
+
+ print "Parsing $filename...\n";
+
+ my $title;
+ my $name;
+ my $keywords;
+ my $subsystem;
+ my $status;
+ my $exit;
+ my $output;
+ my $description;
+ while (<FILE>) {
+ if (/^title: (.*)/) { $title = $1; }
+ if (/^name: (.*)/) { $name = $1; }
+ if (/^keywords: (.*)/) { $keywords = $1; }
+ if (/^subsystem: (.*)/) { $subsystem = $1; }
+ if (/^status: (.*)/) { $status = $1; }
+ if (/^exit: (.*)/) { $exit = $1; }
+ if (/^output: (.*)/) { $output = $1; }
+ if (/^description: (.*)/) { $description = $1; }
+ }
+ close FILE;
+
+ # Remove extra whitespace
+ $keywords =~ s/^\s*//;
+ $keywords =~ s/\s*$//;
+ $subsystem =~ s/^\s*//;
+ $subsystem =~ s/\s*$//;
+
+ # The subdir without the inputdir prefix, nor any slashes.
+ my $subdir = substr $File::Find::dir, (length $inputdir);
+ $subdir =~ s/^\///;
+ if ($subdir ne "") {
+ $name = "$subdir/$name";
+ }
+
+ my $script = {
+ name => $name,
+ title => $title,
+ keywords => $keywords,
+ subsystem => $subsystem,
+ status => $status,
+ exit => $exit,
+ output => $output,
+ description => $description
+ };
+
+ # chop off the search dir prefix.
+ $inputdir =~ s/\/$//;
+ $meta = substr $filename, (length $inputdir) + 1;
+ $scripts{$meta} = $script;
+
+ # Put .stp script in output dir if necessary and create
+ # subdirs if they don't exist yet.
+ if ($inputdir ne $outputdir) {
+ # The subdir without the inputdir prefix, nor any slashes.
+ my $destdir = substr $File::Find::dir, (length $inputdir);
+ $destdir =~ s/^\///;
+ if ($subdir ne "") {
+ if (! -d "$outputdir/$subdir") {
+ mkpath("$outputdir/$subdir", 1, 0711);
+ }
+ }
+ my $orig = substr $name, (length $subdir);
+ $orig =~ s/^\///;
+ my $dest = "$outputdir/$name";
+ print "Copying $orig to $dest...\n";
+ copy($orig, $dest) or die "$orig cannot be copied to $dest, $!";
+ }
+ }
+}
diff --git a/testsuite/systemtap.examples/html_footer.tmpl b/testsuite/systemtap.examples/html_footer.tmpl
new file mode 100644
index 00000000..27eccd3c
--- /dev/null
+++ b/testsuite/systemtap.examples/html_footer.tmpl
@@ -0,0 +1,14 @@
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <table cellspacing="2" cellpadding="2" border="0" width="100%">
+ <tr>
+ <td align="center" class="footer"><a href=
+ "http://sourceware.org/systemtap">SystemTap</a></td>
+ </tr>
+ </table>
+</body>
+</html>
diff --git a/testsuite/systemtap.examples/html_header.tmpl b/testsuite/systemtap.examples/html_header.tmpl
new file mode 100644
index 00000000..33ce558f
--- /dev/null
+++ b/testsuite/systemtap.examples/html_header.tmpl
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+ <title>SystemTap Examples</title>
+ <link rel="stylesheet" href="systemtap.css" type="text/css">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta http-equiv="Content-Style-Type" content="text/css">
+</head>
+
+<body>
+ <table cellspacing="2" cellpadding="2" border="0" width="100%">
+ <tr>
+ <td valign="bottom" height="80"><img src="systemtaplogo.png"
+ alt="SystemTap logo" width="165" height="25"></td>
+ <td valign="bottom" class="topnavright" align="right">
+ <a href="http://sourceware.org/systemtap/">SystemTap</a>&nbsp;|&nbsp;
+ </td>
+ </tr>
+ </table>
+
+ <div class="mainbackground">
+ <div class="maintextregion">
+ <img src="systemtapcorner.gif">
+ <table cellspacing="2" cellpadding="4" border="0" width="99%"
+ style="margin-top:17;">
+ <tr>
+ <td width="200">&nbsp;</td>
+ <td valign="bottom"><h1>Examples</h1></td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ <td valign="top">
+
+ <h2>Example Indexes</h2>
+ <ul>
+ <li><a href="index.html">All Examples</a></li>
+ <li><a href="subsystem-index.html">By Subsystem</a></li>
+ <li><a href="keyword-index.html">By Keyword</a></li>
+ </ul>
+
diff --git a/testsuite/systemtap.examples/systemtap.css b/testsuite/systemtap.examples/systemtap.css
new file mode 100644
index 00000000..445d95f4
--- /dev/null
+++ b/testsuite/systemtap.examples/systemtap.css
@@ -0,0 +1,164 @@
+body {
+ background-color: #cccccc;
+}
+
+.topnavright {
+ color: #787878;
+ text-align: right;
+ font-family: verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size: 14px;
+ margin-right: 10px;
+}
+
+.topnavright a:link {
+ text-decoration: none;
+ color: #944E0F;
+}
+
+.topnavright a:visited {
+ text-decoration: none;
+ color: #944E0F;
+}
+
+div.mainbackground {
+ background-color: #ffffff;
+ padding: 17 17 17 17;
+}
+
+div.maintextregion {
+ background-color: #5b5b5b;
+ color: #ffffff;
+}
+
+div.maintextregion h1 {
+ color: #F38019;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size: 28px
+}
+
+div.maintextregion h2 {
+ color: #F38019;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ margin-bottom: 2px;
+ font-size: 18px;
+ margin-top: 28px;
+}
+
+div.maintextregion h4 {
+ color: #ffffff;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+}
+
+div.maintextregion p {
+ color: #ffffff;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size: 14px;
+ line-height: 150%;
+ text-align: justify;
+}
+
+div.maintextregion ul {
+ color: #ffffff;
+ list-style-type: square;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size: 14px;
+ line-height: 150%;
+ text-align: justify;
+}
+
+div.maintextregion td ul ul {
+ color: #ffffff;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+
+div.maintextregion dt {
+ color: #ffffff;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ margin-top: 10px;
+}
+
+div.maintextregion pre {
+ color: #ffffff;
+ font-size: 14px;
+}
+
+div.maintextregion td pre {
+ color: #ffffff;
+ font-size: 14px;
+}
+
+div.maintextregion dd {
+ color: #ffffff;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size: 14px;
+ line-height: 150%;
+ text-align: justify;
+ margin-left: 10px;
+}
+
+div.maintextregion table {
+ margin-top: 20;
+}
+
+div.maintextregion th {
+ color: #ffffff;
+ background-color: #494949;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ text-align: left;
+}
+
+div.maintextregion tr.odd {
+ color: #ffffff;
+ background-color: #393939;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+
+div.maintextregion tr.even {
+ color: #ffffff;
+ background-color: #4d4d4d;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+
+div.maintextregion form {
+ color: #ffffff;
+ background-color: #4d4d4d;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+ border: thin solid #424242;
+ padding: 6;
+}
+
+div.maintextregion dd.left {
+ color: #ffffff;
+ margin-left: 0;
+}
+
+a:link {
+ color: #ff9600;
+ text-decoration: none;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+
+a:visited {
+ color: #ff9600;
+ text-decoration: none;
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+
+.imgholder {
+ text-align: center;
+ padding: 8;
+}
+.footer a:link {
+ text-decoration: none;
+ color: #944E0F;
+ font-size: 12px;
+ font-weight: bold;
+}
+.footer a:visited {
+ text-decoration: none;
+ color: #944E0F;
+ font-size: 12px;
+ font-weight: bold;
+}
+
diff --git a/testsuite/systemtap.examples/systemtapcorner.gif b/testsuite/systemtap.examples/systemtapcorner.gif
new file mode 100644
index 00000000..c44f2c75
--- /dev/null
+++ b/testsuite/systemtap.examples/systemtapcorner.gif
Binary files differ
diff --git a/testsuite/systemtap.examples/systemtaplogo.png b/testsuite/systemtap.examples/systemtaplogo.png
new file mode 100644
index 00000000..c223babd
--- /dev/null
+++ b/testsuite/systemtap.examples/systemtaplogo.png
Binary files differ