[LTP] [PATCH v2 5/6] tools: Remove tools used by runltp
Petr Vorel
pvorel@suse.cz
Thu Feb 5 13:15:39 CET 2026
restore_kernel_faults_default.sh and insert_kernel_faults.sh were used
by create_kernel_faults_in_loops_and_probability.awk, other tools
(create_dmesg_entries_for_each_test.awk, create_valgrind_check.awk,
create_kernel_faults_in_loops_and_probability.awk, genhtml.pl, genload,
html_report_header.txt) directly by runltp.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
tools/Makefile | 2 +-
tools/create_dmesg_entries_for_each_test.awk | 35 -
...kernel_faults_in_loops_and_probability.awk | 40 -
tools/create_valgrind_check.awk | 42 -
tools/genhtml.pl | 249 -----
tools/genload/.gitignore | 2 -
tools/genload/Makefile | 31 -
tools/genload/README | 72 --
tools/genload/genload.c | 898 ------------------
tools/genload/stress.c | 898 ------------------
tools/html_report_header.txt | 56 --
tools/insert_kernel_faults.sh | 53 --
tools/restore_kernel_faults_default.sh | 86 --
13 files changed, 1 insertion(+), 2463 deletions(-)
delete mode 100644 tools/create_dmesg_entries_for_each_test.awk
delete mode 100644 tools/create_kernel_faults_in_loops_and_probability.awk
delete mode 100644 tools/create_valgrind_check.awk
delete mode 100644 tools/genhtml.pl
delete mode 100644 tools/genload/.gitignore
delete mode 100644 tools/genload/Makefile
delete mode 100644 tools/genload/README
delete mode 100644 tools/genload/genload.c
delete mode 100644 tools/genload/stress.c
delete mode 100644 tools/html_report_header.txt
delete mode 100755 tools/insert_kernel_faults.sh
delete mode 100755 tools/restore_kernel_faults_default.sh
diff --git a/tools/Makefile b/tools/Makefile
index adbf4fe70b..e31af5fcdf 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -24,7 +24,7 @@ top_srcdir ?= ..
include $(top_srcdir)/include/mk/testcases.mk
-INSTALL_TARGETS := *.awk *.pl *.sh html_report_header.txt
+INSTALL_TARGETS := *.sh
INSTALL_DIR := bin
diff --git a/tools/create_dmesg_entries_for_each_test.awk b/tools/create_dmesg_entries_for_each_test.awk
deleted file mode 100644
index b21364ae06..0000000000
--- a/tools/create_dmesg_entries_for_each_test.awk
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/awk -f
-#
-# Script for adding necessary dmesg clear/capture calls before executing
-# commands.
-#
-# Copyright (C) 2012, Linux Test Project.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, April 2012
-#
-
-NF && ! /^#/ {
- s = $1 "__with_dmesg_entry dmesg -c 1>/dev/null 2>&1;"
- for (i = 2; i <= NF; i++) {
- s = s " " $i
- }
- sub(/[;]+$/, "", s)
- s = s "; EXIT_CODE=$?"
- s = s "; dmesg > " DMESG_DIR "/" $1 ".dmesg.log"
- s = s "; exit $EXIT_CODE"
- print s
-}
diff --git a/tools/create_kernel_faults_in_loops_and_probability.awk b/tools/create_kernel_faults_in_loops_and_probability.awk
deleted file mode 100644
index e2ec3b515d..0000000000
--- a/tools/create_kernel_faults_in_loops_and_probability.awk
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/awk -f
-#
-# Script for adding necessary dmesg clear/capture calls before executing
-# commands.
-#
-# Copyright (C) 2012, Linux Test Project.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, April 2012
-#
-
-NF && ! /^#/ {
- print
- for (i = 1; i <= LOOPS; i++) {
- s = $1 "_loop_" i "_under_fault_kernel "
- if (i == 1) {
- s = s "$LTPROOT/bin/insert_kernel_faults.sh " PERCENTAGE "; "
- }
- for (j = 2; j <= NF; j++) {
- s = s " " $j
- }
- if (i == LOOPS) {
- s = s "; while ! $LTPROOT/bin/restore_kernel_faults_default.sh; do :; done"
- }
- print s
- }
-}
diff --git a/tools/create_valgrind_check.awk b/tools/create_valgrind_check.awk
deleted file mode 100644
index 05cf6fac4b..0000000000
--- a/tools/create_valgrind_check.awk
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/awk -f
-#
-# Script for adding necessary valgrind calls before commands.
-#
-# Copyright (C) 2012, Linux Test Project.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, April 2012
-#
-
-# XXX: this script doesn't handle items that would be executed via pan with
-# /bin/sh properly.
-NF && ! /^#/ {
- print
- if (CHECK_LEVEL == 1 || CHECK_LEVEL == 3) {
- s=$1 "_valgrind_memory_leak_check valgrind -q --leak-check=full --trace-children=yes"
- for (i = 2; i <= NF; i++) {
- s = s " " $i
- }
- print s
- }
- if (CHECK_LEVEL == 2 || CHECK_LEVEL == 3) {
- s=$1 "_valgrind_thread_concurrency_check valgrind -q --tool=helgrind --trace-children=yes"
- for (i = 2; i <= NF; i++) {
- s = s " " $i
- }
- print s
- }
-}
diff --git a/tools/genhtml.pl b/tools/genhtml.pl
deleted file mode 100644
index 79c178d014..0000000000
--- a/tools/genhtml.pl
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/perl
-#****************************************************************************#
-# Copyright (c) International Business Machines Corp., 2001 #
-# #
-# This program is free software; you can redistribute it an#or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation; either version 2 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See #
-# the GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program; if not, write to the Free Software #
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #
-# #
-#****************************************************************************#
-
-#****************************************************************************#
-# #
-# File: genhtml.pl #
-# #
-# Description: This is a Parser which can parse the text output generated by #
-# pan and convert the same to am HTML format, with proper high- #
-# lighting of test result backgorund for easy identification of #
-# pass/fail of testcases #
-# #
-# Author: Subrata Modak: subrata@linux.vnet.ibm.com #
-# #
-# #
-#****************************************************************************#
-
-
-my $process_line = 0;
-my $row_line = "";
-my $flag = 0;
-my $flag2 = 0;
-my $flag3 = 0;
-my $flag4 = 0;
-my $test_counter = 1;
-my $failed_test_counter = 0;
-my $failed_test_counter_flag = 0;
-my $brok_test_counter = 0;
-my $brok_test_counter_flag = 0;
-my $warn_test_counter = 0;
-my $warn_test_counter_flag = 0;
-my $retr_test_counter = 0;
-my $retr_test_counter_flag = 0;
-my $conf_test_counter = 0;
-my $conf_test_counter_flag = 0;
-my $test_passed = 0;
-
-my $detected_fail = 0;
-my $detected_pass = 0;
-my $detected_warn = 0;
-my $detected_brok = 0;
-my $detected_retr = 0;
-my $detected_conf = 0;
-my $background_colour =0;
-
-my $header_file = shift (@ARGV) || syntax();
-my $start_tag = shift (@ARGV) || syntax();
-my $end_tag = shift (@ARGV) || syntax();
-my $output_tag = shift (@ARGV) || syntax();
-my $execution_tag = shift (@ARGV) || syntax();
-
-sub syntax() {
- print "syntax: prtag2tag start_tag end_tag output_tag execution_tag file(s)\n";
- exit (1);
-}
-
-sub get_background_colour_column() {
- if ( $detected_fail == 1 ) {
- return "#ff0000";
- } elsif ( $detected_brok == 1 ) {
- return Yellow;
- } elsif ( $detected_warn == 1 ) {
- return Fuchsia;
- } elsif ( $detected_retr == 1 ) {
- return "#8dc997";
- } elsif ( $detected_conf == 1 ) {
- return Aqua;
- } else {
- return "#66ff66";
- }
-}
-
-print STDERR "-------------------------------------------------\n";
-print STDERR "INFO: genhtml.pl script is deprecated, try kirk\n";
-print STDERR "(new LTP runner which also generates JSON output)\n";
-print STDERR "https://github.com/linux-test-project/kirk\n";
-print STDERR "-------------------------------------------------\n";
-
-if ($start_tag eq "" || $end_tag eq "" || $output_tag eq "" || $execution_tag eq "") {
- syntax();
-}
-
-open (FILE, "$header_file") || "Cannot open file: $header_file";
-while ($line_2 = <FILE>) {
- $row_line = $row_line . $line_2;
-}
-$row_line =~ s/LTP\ Output\/Log/LTP\ Output\/Log\ (Report\ Generated\ on\ $ENV{TEST_START_TIME})/;
-print $row_line;
-close (FILE);
-$row_line = "";
-
-
-foreach my $file (@ARGV) {
-
- open (FILE, $file) || die "Cannot open file: $file\n";
-
- LINE: while ($line = <FILE>) {
- chomp $line;
-
- if ($line =~ /$start_tag/) {
- $process_line = 1;
- $flag = 1;
- }
- if ($line =~ /$end_tag/) {
- print "$row_line";
- $process_line = 0;
- $flag = 0; $flag2 = 0; $flag3 = 0; $flag4 = 0; $flag5 = 0;
- $detected_fail = 0; $detected_pass = 0; $detected_warn = 0; $detected_brok = 0; $detected_retr = 0; $detected_conf = 0;
- $background_colour = 0; $failed_test_counter_flag = 0; $brok_test_counter_flag = 0; $warn_test_counter_flag = 0; $retr_test_counter_flag = 0; $conf_test_counter_flag = 0; $row_line= "";
- }
-
- if ($process_line) {
- if ( $flag == 2) { #Assuming we will find "tag" and "stime" values here
- @variable_value_pair = split(/\ /, $line);
- @tag_value = split(/=/,$variable_value_pair[0]);
- @stime_value = split(/=/,$variable_value_pair[1]);
- $row_line = $row_line . "<tr><td><p><strong>$test_counter</strong></p></td>\n" .
- "<td><p><strong>$tag_value[1]</strong></p></td>\n" .
- "<td><p><pre><strong>";
- $get_proper_time = localtime ($stime_value[1]);
- $row_line = $row_line . "$get_proper_time" . "</strong></pre></p></td>\n";
- $test_counter++;
- }
- if ( $flag == 3) { #Assuming we will find "cmdling" value here
- @variable_value_pair = split(/=/, $line);
- $row_line = $row_line . "<td><p><strong> $variable_value_pair[1] </strong></p></td>\n";
- }
- if ( $flag == 4) { #Assuming we will find "contact" value here
- @variable_value_pair = split(/=/, $line);
- $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
- }
- if ( $flag == 5) { #Assuming we will find "analysis" value here
- @variable_value_pair = split(/=/, $line);
- $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
- }
- if ( $flag3 == 1 ) {
- if ( $flag4 == 1 ) {
- @variable_value_pair = split(/=/, $line);
- $row_line = $row_line . "<td><p><strong>$variable_value_pair[1]</strong></p></td>\n";
- }
- if ( $flag4 == 2 ) {
- @variable_value_pair = split(/\ /, $line);
- @duration_value = split(/=/, $variable_value_pair[0]);
- @termination_type_value = split(/=/, $variable_value_pair[1]);
- @termination_id_value = split(/=/, $variable_value_pair[2]);
- @corefile_value = split(/=/, $variable_value_pair[3]);
- $background_colour = get_background_colour_column();
- $row_line = $row_line . "<td><p><strong>$duration_value[1]</strong></p></td>\n" .
- "<td><p><strong>$termination_type_value[1]<strong></p></td>\n" .
- "<td><p><strong>$termination_id_value[1]</strong></p></td>\n" .
- "<td><p><strong>$corefile_value[1]</strong></p></td>\n";
- $row_line =~ s/<tr>/<tr\ bgcolor=$background_colour>/;
- $flag4++;
- }
- if ( $flag4 == 3 ) {
- @variable_value_pair = split(/\ /, $line);
- @cutime_value = split(/=/, $variable_value_pair[0]);
- @cstime_value = split(/=/, $variable_value_pair[1]);
- $row_line = $row_line . "<td><p><strong>$cutime_value[1]</strong></p></td>\n" .
- "<td><p><strong>$cstime_value[1]</strong></p></td></tr>\n";
- }
- }
- if ( $line =~ /$execution_tag/ ) {
- $flag2 = 0;
- $flag3 = 1;
- $flag4 = 1;
- $flag5 = 1;
- $row_line = $row_line . "</strong></pre></td>";
- }
- if ( $flag2 == 1 ) {
- $row_line = $row_line . "$line \n";
- }
- if ( $flag5 == 1 ) {
- if ($line =~ "termination_id=1" ) {
- $detected_fail = 1;
- $failed_test_counter++;
- $flag4 = 2;
- } elsif ($line =~ "termination_id=2" ) {
- $detected_brok = 1;
- $brok_test_counter++;
- $flag4 = 2;
- } elsif ($line =~ "termination_id=4" ) {
- $detected_warn = 1;
- $warn_test_counter++;
- $flag4 = 2;
- } elsif ($line =~ "termination_id=32" ) {
- $detected_conf = 1;
- $conf_test_counter++;
- $flag4 = 2;
- } elsif ($line =~ "termination_id=0" ) {
- $detected_pass = 1;
- $test_passed++;
- $flag4 = 2;
- }
- }
- if ( $line =~ /$output_tag/ ) {
- $flag2 = 1;
- $row_line = $row_line . "<td><pre><strong>";
- }
- $flag++;
- }
- }
- close (FILE);
-}
-
-print "</tbody></table></div> \n\n<h2 id=\"_2\">Summary Report</h2>\n\n<div>\n\n<table border=\"1\" cellspacing=\"3\"><tbody>\n<tr>\n<td ";
-if ($ENV{LTP_EXIT_VALUE} == 1 ) {
- print "bgcolor=\"#ff0000\"> <strong>Test Summary</strong></p></td><td bgcolor=\"#ff0000\"><strong>Pan reported some Tests FAIL</strong></p></td></tr>\n";
-}
-else {
- print "bgcolor=\"#66ff66\"> <strong>Test Summary</strong></p></td><td bgcolor=\"#66ff66\"><strong>Pan reported all Test Pass</strong></p></td></tr>\n";
-}
-
-print "<tr><td><strong>LTP Version</strong> </td><td><strong> $ENV{LTP_VERSION} </strong></td></tr>\n";
-print "<tr><td><strong>Start Time</strong> </td><td><strong> $ENV{TEST_START_TIME} </strong></td></tr>\n";
-print "<tr><td><strong>End Time</strong> </td><td><strong> $ENV{TEST_END_TIME} </strong></td></tr>\n";
-print "<tr><td><strong>Log Result</strong> </td><td><a href=\"file://$ENV{TEST_LOGS_DIRECTORY}/\"> <strong>$ENV{TEST_LOGS_DIRECTORY}</strong></a></td></tr>\n";
-print "<tr><td><strong>Output/Failed Result</strong></td><td><a href=\"file://$ENV{TEST_OUTPUT_DIRECTORY}/\"> <strong>$ENV{TEST_OUTPUT_DIRECTORY}</strong></a></td></tr>\n";
-print "<tr><td><strong>Total Tests</strong></td><td><strong>";
-$test_counter--;
-print "$test_counter </strong></td></tr>\n";
-$test_passed=$test_counter-$failed_test_counter-$brok_test_counter-$warn_test_counter-$retr_test_counter-$conf_test_counter;
-print "<tr><td><strong>Total Test TPASS:</strong></td><td><strong> $test_passed </strong></td></tr>\n";
-print "<tr><td><strong>Total Test TFAIL:</strong></td><td><strong> $failed_test_counter </strong></td></tr>\n";
-print "<tr><td><strong>Total Test TBROK</strong></td><td><strong> $brok_test_counter </strong></td></tr>\n";
-print "<tr><td><strong>Total Test TWARN</strong></td><td><strong> $warn_test_counter </strong></td></tr>\n";
-print "<tr><td><strong>Total Test TCONF</strong></td><td><strong> $conf_test_counter </strong></td></tr>\n";
-print "<tr><td><strong>Kernel Version</strong></td><td><strong> $ENV{KERNEL_VERSION} </strong></td></tr>\n";
-print "<tr><td><strong>Machine Architecture</strong></td><td><strong> $ENV{MACHINE_ARCH} </strong></td></tr>\n";
-print "<tr><td><strong>Hostname</strong> </td> <td><strong>";
-$hostname=system("uname -n"); chop($hostname);
-print " $hostname </strong></td></tr></tbody></table></div></body></html>\n";
diff --git a/tools/genload/.gitignore b/tools/genload/.gitignore
deleted file mode 100644
index b89b36741b..0000000000
--- a/tools/genload/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-genload
-stress
diff --git a/tools/genload/Makefile b/tools/genload/Makefile
deleted file mode 100644
index 8bf4d27558..0000000000
--- a/tools/genload/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# tools/genload Makefile.
-#
-# Copyright (C) 2009, Cisco Systems Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
-
-top_srcdir ?= ../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-CFLAGS += -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\"
-
-LDLIBS += -lm
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/tools/genload/README b/tools/genload/README
deleted file mode 100644
index 7ea37f6634..0000000000
--- a/tools/genload/README
+++ /dev/null
@@ -1,72 +0,0 @@
-USAGE
-
-See the program's usage statement by invoking with --help.
-
-NOTES
-
-This program works really well for me, but it might not have some of the
-features that you want. If you would like, please extend the code and send
-me the patch[1]. Enjoy the program :-)
-
-Please use the context diff format. That is: save the original program
-as stress.c.orig, then make and test your desired changes to stress.c, then
-run 'diff -u stress.c.orig stress.c' to produce a context patch. Thanks.
-
-Amos Waterland <apw@rossby.metr.ou.edu>
-Norman, Oklahoma
-27 Nov 2001
-
-EXAMPLES
-[examples]
-
-The simple case is that you just want to bring the system load average up to
-an arbitrary value. The following forks 13 processes, each of which spins
-in a tight loop calculating the sqrt() of a random number acquired with
-rand().
-
- % stress -c 13
-
-Long options are supported, as well as is making the output less verbose.
-The following forks 1024 processes, and only reports error messages if any.
-
- % stress --quiet --hogcpu 1k
-
-To see how your system performs when it is I/O bound, use the -i switch.
-The following forks 4 processes, each of which spins in a tight loop calling
-sync(), which is a system call that flushes memory buffers to disk.
-
- % stress -i 4
-
-Multiple hogs may be combined on the same command line. The following does
-everything the preceding examples did in one command, but also turns up the
-verbosity level as well as showing how to cause the command to
-self-terminate after 1 minute.
-
- % stress -c 13 -i 4 --verbose --timeout 1m
-
-An value of 0 normally denotes infinity. The following is how to do a fork
-bomb (be careful with this).
-
- % stress -c 0
-
-For the -m and -d options, a value of 0 means to redo their operation an
-infinite number of times. To allocate and free 128MB in a redo loop use the
-following command. This can be useful for "bouncing" against the system RAM
-ceiling.
-
- % stress -m 0 --hogvm-bytes 128M
-
-For the -m and -d options, a negative value of n means to redo the operation
-abs(n) times. Here is now to allocate and free 5MB three times in a row.
-
- % stress -m -3 --hogvm-bytes 5m
-
-You can write a file of arbitrary length to disk. The file is created with
-mkstemp() in the current directory, the default is to unlink it, but
-unlinking can be overridden with the --hoghdd-noclean flag.
-
- % stress -d 1 --hoghdd-noclean --hoghdd-bytes 13
-
-Large file support is enabled.
-
- % stress -d 1 --hoghdd-noclean --hoghdd-bytes 3G
diff --git a/tools/genload/genload.c b/tools/genload/genload.c
deleted file mode 100644
index a19d519fd6..0000000000
--- a/tools/genload/genload.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/* A program to put stress on a POSIX system (stress).
- *
- * Copyright (C) 2001, 2002 Amos Waterland <awaterl@yahoo.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <libgen.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/wait.h>
-
-/* By default, print all messages of severity info and above. */
-static int global_debug = 2;
-
-/* By default, just print warning for non-critical errors. */
-static int global_ignore = 1;
-
-/* By default, retry on non-critical errors every 50ms. */
-static int global_retry = 50000;
-
-/* By default, use this as backoff coefficient for good fork throughput. */
-static int global_backoff = 3000;
-
-/* By default, do not timeout. */
-static int global_timeout = 0;
-
-/* Name of this program */
-static char *global_progname = PACKAGE;
-
-/* By default, do not hang after allocating memory. */
-static int global_vmhang = 0;
-
-/* Implemention of runtime-selectable severity message printing. */
-#define dbg if (global_debug >= 3) \
- fprintf (stdout, "%s: debug: (%d) ", global_progname, __LINE__), \
- fprintf
-#define out if (global_debug >= 2) \
- fprintf (stdout, "%s: info: ", global_progname), \
- fprintf
-#define wrn if (global_debug >= 1) \
- fprintf (stderr, "%s: warn: (%d) ", global_progname, __LINE__), \
- fprintf
-#define err if (global_debug >= 0) \
- fprintf (stderr, "%s: error: (%d) ", global_progname, __LINE__), \
- fprintf
-
-/* Implementation of check for option argument correctness. */
-#define assert_arg(A) \
- if (++i == argc || ((arg = argv[i])[0] == '-' && \
- !isdigit ((int)arg[1]) )) \
- { \
- err (stderr, "missing argument to option '%s'\n", A); \
- exit (1); \
- }
-
-/* Prototypes for utility functions. */
-int usage(int status);
-int version(int status);
-long long atoll_s(const char *nptr);
-long long atoll_b(const char *nptr);
-
-/* Prototypes for the worker functions. */
-int hogcpu(long long forks);
-int hogio(long long forks);
-int hogvm(long long forks, long long chunks, long long bytes);
-int hoghdd(long long forks, int clean, long long files, long long bytes);
-
-int main(int argc, char **argv)
-{
- int i, pid, children = 0, retval = 0;
- long starttime, stoptime, runtime;
-
- /* Variables that indicate which options have been selected. */
- int do_dryrun = 0;
- int do_timeout = 0;
- int do_cpu = 0; /* Default to 1 fork. */
- long long do_cpu_forks = 1;
- int do_io = 0; /* Default to 1 fork. */
- long long do_io_forks = 1;
- int do_vm = 0; /* Default to 1 fork, 1 chunk of 256MB. */
- long long do_vm_forks = 1;
- long long do_vm_chunks = 1;
- long long do_vm_bytes = 256 * 1024 * 1024;
- int do_hdd = 0; /* Default to 1 fork, clean, 1 file of 1GB. */
- long long do_hdd_forks = 1;
- int do_hdd_clean = 0;
- long long do_hdd_files = 1;
- long long do_hdd_bytes = 1024 * 1024 * 1024;
-
- /* Record our start time. */
- if ((starttime = time(NULL)) == -1) {
- err(stderr, "failed to acquire current time\n");
- exit(1);
- }
-
- /* SuSv3 does not define any error conditions for this function. */
- global_progname = basename(argv[0]);
-
- /* For portability, parse command line options without getopt_long. */
- for (i = 1; i < argc; i++) {
- char *arg = argv[i];
-
- if (strcmp(arg, "--help") == 0 || strcmp(arg, "-?") == 0) {
- usage(0);
- } else if (strcmp(arg, "--version") == 0) {
- version(0);
- } else if (strcmp(arg, "--verbose") == 0
- || strcmp(arg, "-v") == 0) {
- global_debug = 3;
- } else if (strcmp(arg, "--quiet") == 0
- || strcmp(arg, "-q") == 0) {
- global_debug = 0;
- } else if (strcmp(arg, "--dry-run") == 0
- || strcmp(arg, "-n") == 0) {
- do_dryrun = 1;
- } else if (strcmp(arg, "--no-retry") == 0) {
- global_ignore = 0;
- dbg(stdout,
- "turning off ignore of non-critical errors");
- } else if (strcmp(arg, "--retry-delay") == 0) {
- assert_arg("--retry-delay");
- global_retry = atoll(arg);
- dbg(stdout, "setting retry delay to %dus\n",
- global_retry);
- } else if (strcmp(arg, "--backoff") == 0) {
- assert_arg("--backoff");
- global_backoff = atoll(arg);
- if (global_backoff < 0) {
- err(stderr, "invalid backoff factor: %i\n",
- global_backoff);
- exit(1);
- }
- dbg(stdout, "setting backoff coeffient to %dus\n",
- global_backoff);
- } else if (strcmp(arg, "--timeout") == 0
- || strcmp(arg, "-t") == 0) {
- do_timeout = 1;
- assert_arg("--timeout");
- global_timeout = atoll_s(arg);
- dbg(stdout, "setting timeout to %ds\n", global_timeout);
- } else if (strcmp(arg, "--cpu") == 0 || strcmp(arg, "-c") == 0) {
- do_cpu = 1;
- assert_arg("--cpu");
- do_cpu_forks = atoll_b(arg);
- } else if (strcmp(arg, "--io") == 0 || strcmp(arg, "-i") == 0) {
- do_io = 1;
- assert_arg("--io");
- do_io_forks = atoll_b(arg);
- } else if (strcmp(arg, "--vm") == 0 || strcmp(arg, "-m") == 0) {
- do_vm = 1;
- assert_arg("--vm");
- do_vm_forks = atoll_b(arg);
- } else if (strcmp(arg, "--vm-chunks") == 0) {
- assert_arg("--vm-chunks");
- do_vm_chunks = atoll_b(arg);
- } else if (strcmp(arg, "--vm-bytes") == 0) {
- assert_arg("--vm-bytes");
- do_vm_bytes = atoll_b(arg);
- } else if (strcmp(arg, "--vm-hang") == 0) {
- global_vmhang = 1;
- } else if (strcmp(arg, "--hdd") == 0 || strcmp(arg, "-d") == 0) {
- do_hdd = 1;
- assert_arg("--hdd");
- do_hdd_forks = atoll_b(arg);
- } else if (strcmp(arg, "--hdd-noclean") == 0) {
- do_hdd_clean = 2;
- } else if (strcmp(arg, "--hdd-files") == 0) {
- assert_arg("--hdd-files");
- do_hdd_files = atoll_b(arg);
- } else if (strcmp(arg, "--hdd-bytes") == 0) {
- assert_arg("--hdd-bytes");
- do_hdd_bytes = atoll_b(arg);
- } else {
- err(stderr, "unrecognized option: %s\n", arg);
- exit(1);
- }
- }
-
- /* Hog CPU option. */
- if (do_cpu) {
- out(stdout, "dispatching %lli hogcpu forks\n", do_cpu_forks);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogcpu(do_cpu_forks));
- case -1: /* error */
- err(stderr, "hogcpu dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogcpu dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog I/O option. */
- if (do_io) {
- out(stdout, "dispatching %lli hogio forks\n", do_io_forks);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogio(do_io_forks));
- case -1: /* error */
- err(stderr, "hogio dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogio dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog VM option. */
- if (do_vm) {
- out(stdout,
- "dispatching %lli hogvm forks, each %lli chunks of %lli bytes\n",
- do_vm_forks, do_vm_chunks, do_vm_bytes);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogvm(do_vm_forks, do_vm_chunks, do_vm_bytes));
- case -1: /* error */
- err(stderr, "hogvm dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogvm dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog HDD option. */
- if (do_hdd) {
- out(stdout, "dispatching %lli hoghdd forks, each %lli files of "
- "%lli bytes\n", do_hdd_forks, do_hdd_files, do_hdd_bytes);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hoghdd
- (do_hdd_forks, do_hdd_clean, do_hdd_files,
- do_hdd_bytes));
- case -1: /* error */
- err(stderr, "hoghdd dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hoghdd dispatcher forked (%i)\n", pid);
- }
- }
-
- /* We have no work to do, so bail out. */
- if (children == 0)
- usage(0);
-
- /* Wait for our children to exit. */
- while (children) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "dispatcher %i returned error %i\n",
- pid, ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- dispatcher return (%i)\n",
- pid);
- }
- } else {
- err(stderr,
- "dispatcher did not exit normally\n");
- ++retval;
- }
-
- --children;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing dispatcher children\n");
- ++retval;
- break;
- }
- }
-
- /* Record our stop time. */
- if ((stoptime = time(NULL)) == -1) {
- err(stderr, "failed to acquire current time\n");
- exit(1);
- }
-
- /* Calculate our runtime. */
- runtime = stoptime - starttime;
-
- /* Print final status message. */
- if (retval) {
- err(stderr, "failed run completed in %lis\n", runtime);
- } else {
- out(stdout, "successful run completed in %lis\n", runtime);
- }
-
- exit(retval);
-}
-
-int usage(int status)
-{
- char *mesg =
- "`%s' imposes certain types of compute stress on your system\n\n"
- "Usage: %s [OPTION [ARG]] ...\n\n"
- " -?, --help show this help statement\n"
- " --version show version statement\n"
- " -v, --verbose be verbose\n"
- " -q, --quiet be quiet\n"
- " -n, --dry-run show what would have been done\n"
- " --no-retry exit rather than retry non-critical errors\n"
- " --retry-delay n wait n us before continuing past error\n"
- " -t, --timeout n timeout after n seconds\n"
- " --backoff n wait for factor of n us before starting work\n"
- " -c, --cpu n spawn n procs spinning on sqrt()\n"
- " -i, --io n spawn n procs spinning on sync()\n"
- " -m, --vm n spawn n procs spinning on malloc()\n"
- " --vm-chunks c malloc c chunks (default is 1)\n"
- " --vm-bytes b malloc chunks of b bytes (default is 256MB)\n"
- " --vm-hang hang in a sleep loop after memory allocated\n"
- " -d, --hdd n spawn n procs spinning on write()\n"
- " --hdd-noclean do not unlink file to which random data written\n"
- " --hdd-files f write to f files (default is 1)\n"
- " --hdd-bytes b write b bytes (default is 1GB)\n\n"
- "Infinity is denoted with 0. For -m, -d: n=0 means infinite redo,\n"
- "n<0 means redo abs(n) times. Valid suffixes are m,h,d,y for time;\n"
- "k,m,g for size.\n\n";
-
- fprintf(stdout, mesg, global_progname, global_progname);
-
- if (status <= 0)
- exit(-1 * status);
-
- return 0;
-}
-
-int version(int status)
-{
- char *mesg = "%s %s\n";
-
- fprintf(stdout, mesg, global_progname, VERSION);
-
- if (status <= 0)
- exit(-1 * status);
-
- return 0;
-}
-
-/* Convert a string representation of a number with an optional size suffix
- * to a long long.
- */
-long long atoll_b(const char *nptr)
-{
- int pos;
- char suffix;
- long long factor = 1;
-
- if ((pos = strlen(nptr) - 1) < 0) {
- err(stderr, "invalid string\n");
- exit(1);
- }
-
- switch (suffix = nptr[pos]) {
- case 'k':
- case 'K':
- factor = 1024;
- break;
- case 'm':
- case 'M':
- factor = 1024 * 1024;
- break;
- case 'g':
- case 'G':
- factor = 1024 * 1024 * 1024;
- break;
- default:
- if (suffix < '0' || suffix > '9') {
- err(stderr, "unrecognized suffix: %c\n", suffix);
- exit(1);
- }
- }
-
- factor = atoll(nptr) * factor;
-
- return factor;
-}
-
-/* Convert a string representation of a number with an optional time suffix
- * to a long long.
- */
-long long atoll_s(const char *nptr)
-{
- int pos;
- char suffix;
- long long factor = 1;
-
- if ((pos = strlen(nptr) - 1) < 0) {
- err(stderr, "invalid string\n");
- exit(1);
- }
-
- switch (suffix = nptr[pos]) {
- case 's':
- case 'S':
- factor = 1;
- break;
- case 'm':
- case 'M':
- factor = 60;
- break;
- case 'h':
- case 'H':
- factor = 60 * 60;
- break;
- case 'd':
- case 'D':
- factor = 60 * 60 * 24;
- break;
- case 'y':
- case 'Y':
- factor = 60 * 60 * 24 * 360;
- break;
- default:
- if (suffix < '0' || suffix > '9') {
- err(stderr, "unrecognized suffix: %c\n", suffix);
- exit(1);
- }
- }
-
- factor = atoll(nptr) * factor;
-
- return factor;
-}
-
-int hogcpu(long long forks)
-{
- long long i;
- double d;
- int pid, retval = 0;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogcpu\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1)
- d = sqrt(rand());
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogcpu worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogcpu worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogcpu worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogcpu worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogcpu worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout,
- "<-- hogcpu worker signalled (%i)\n", pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr,
- "detected missing hogcpu worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hogio(long long forks)
-{
- long long i;
- int pid, retval = 0;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogio\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1)
- sync();
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogio worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogio worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogio worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogio worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogio worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout, "<-- hogio worker signalled (%i)\n",
- pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing hogio worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hogvm(long long forks, long long chunks, long long bytes)
-{
- long long i, j, k;
- int pid, retval = 0;
- char **ptr;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogvm\n", backoff);
-
- if (bytes == 0) {
- /* 512MB is guess at the largest value can than be malloced at once. */
- bytes = 512 * 1024 * 1024;
- }
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- /* If chunks is 0, ptr will allocate 0 bytes's
- * memory, it will cause the process to crash
- * during runtime, so adjust to 1 */
- if (chunks == 0)
- chunks = 1;
-
- while (1) {
- ptr = (char **)malloc(chunks *
- sizeof(char *));
- for (j = 0; j < chunks; j++) {
- if ((ptr[j] =
- (char *)malloc(bytes *
- sizeof(char)))) {
- for (k = 0; k < bytes; k++)
- ptr[j][k] = 'Z'; /* Ensure that COW happens. */
- dbg(stdout,
- "hogvm worker malloced %lli bytes\n",
- k);
- } else if (ignore) {
- ++retval;
- wrn(stderr,
- "hogvm malloc failed, continuing\n");
- usleep(retry);
- continue;
- } else {
- ++retval;
- err(stderr,
- "hogvm malloc failed\n");
- break;
- }
- }
- if (global_vmhang && retval == 0) {
- dbg(stdout,
- "sleeping forever with allocated memory\n");
- while (1)
- sleep(1024);
- }
- if (retval == 0) {
- dbg(stdout,
- "hogvm worker freeing memory and starting over\n");
- for (j = 0; j < chunks; j++)
- free(ptr[j]);
- free(ptr);
- continue;
- }
-
- exit(retval);
- }
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogvm worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogvm worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogvm worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogvm worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogvm worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout, "<-- hogvm worker signalled (%i)\n",
- pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing hogvm worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hoghdd(long long forks, int clean, long long files, long long bytes)
-{
- long long i, j;
- int fd, pid, retval = 0;
- int chunk = (1024 * 1024) - 1; /* Minimize slow writing. */
- char buff[chunk];
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- /* Initialize buffer with some random ASCII data. */
- dbg(stdout, "seeding buffer with random data\n");
- for (i = 0; i < chunk - 1; i++) {
- j = rand();
- j = (j < 0) ? -j : j;
- j %= 95;
- j += 32;
- buff[i] = j;
- }
- buff[i] = '\n';
-
- dbg(stdout, "using backoff sleep of %lius for hoghdd\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1) {
- for (i = 0; i < files; i++) {
- char name[] = "./stress.XXXXXX";
-
- if ((fd = mkstemp(name)) < 0) {
- perror("mkstemp");
- err(stderr, "mkstemp failed\n");
- exit(1);
- }
-
- if (clean == 0) {
- dbg(stdout, "unlinking %s\n",
- name);
- if (unlink(name)) {
- err(stderr,
- "unlink failed\n");
- exit(1);
- }
- }
-
- dbg(stdout, "fast writing to %s\n",
- name);
- for (j = 0;
- bytes == 0 || j + chunk < bytes;
- j += chunk) {
- if (write(fd, buff, chunk) !=
- chunk) {
- err(stderr,
- "write failed\n");
- exit(1);
- }
- }
-
- dbg(stdout, "slow writing to %s\n",
- name);
- for (; bytes == 0 || j < bytes - 1; j++) {
- if (write(fd, "Z", 1) != 1) {
- err(stderr,
- "write failed\n");
- exit(1);
- }
- }
- if (write(fd, "\n", 1) != 1) {
- err(stderr, "write failed\n");
- exit(1);
- }
- ++j;
-
- dbg(stdout,
- "closing %s after writing %lli bytes\n",
- name, j);
- close(fd);
-
- if (clean == 1) {
- if (unlink(name)) {
- err(stderr,
- "unlink failed\n");
- exit(1);
- }
- }
- }
- if (retval == 0) {
- dbg(stdout,
- "hoghdd worker starting over\n");
- continue;
- }
-
- exit(retval);
- }
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hoghdd worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hoghdd worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hoghdd worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hoghdd worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hoghdd worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout,
- "<-- hoghdd worker signalled (%i)\n", pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr,
- "detected missing hoghdd worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
diff --git a/tools/genload/stress.c b/tools/genload/stress.c
deleted file mode 100644
index a19d519fd6..0000000000
--- a/tools/genload/stress.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/* A program to put stress on a POSIX system (stress).
- *
- * Copyright (C) 2001, 2002 Amos Waterland <awaterl@yahoo.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <libgen.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/wait.h>
-
-/* By default, print all messages of severity info and above. */
-static int global_debug = 2;
-
-/* By default, just print warning for non-critical errors. */
-static int global_ignore = 1;
-
-/* By default, retry on non-critical errors every 50ms. */
-static int global_retry = 50000;
-
-/* By default, use this as backoff coefficient for good fork throughput. */
-static int global_backoff = 3000;
-
-/* By default, do not timeout. */
-static int global_timeout = 0;
-
-/* Name of this program */
-static char *global_progname = PACKAGE;
-
-/* By default, do not hang after allocating memory. */
-static int global_vmhang = 0;
-
-/* Implemention of runtime-selectable severity message printing. */
-#define dbg if (global_debug >= 3) \
- fprintf (stdout, "%s: debug: (%d) ", global_progname, __LINE__), \
- fprintf
-#define out if (global_debug >= 2) \
- fprintf (stdout, "%s: info: ", global_progname), \
- fprintf
-#define wrn if (global_debug >= 1) \
- fprintf (stderr, "%s: warn: (%d) ", global_progname, __LINE__), \
- fprintf
-#define err if (global_debug >= 0) \
- fprintf (stderr, "%s: error: (%d) ", global_progname, __LINE__), \
- fprintf
-
-/* Implementation of check for option argument correctness. */
-#define assert_arg(A) \
- if (++i == argc || ((arg = argv[i])[0] == '-' && \
- !isdigit ((int)arg[1]) )) \
- { \
- err (stderr, "missing argument to option '%s'\n", A); \
- exit (1); \
- }
-
-/* Prototypes for utility functions. */
-int usage(int status);
-int version(int status);
-long long atoll_s(const char *nptr);
-long long atoll_b(const char *nptr);
-
-/* Prototypes for the worker functions. */
-int hogcpu(long long forks);
-int hogio(long long forks);
-int hogvm(long long forks, long long chunks, long long bytes);
-int hoghdd(long long forks, int clean, long long files, long long bytes);
-
-int main(int argc, char **argv)
-{
- int i, pid, children = 0, retval = 0;
- long starttime, stoptime, runtime;
-
- /* Variables that indicate which options have been selected. */
- int do_dryrun = 0;
- int do_timeout = 0;
- int do_cpu = 0; /* Default to 1 fork. */
- long long do_cpu_forks = 1;
- int do_io = 0; /* Default to 1 fork. */
- long long do_io_forks = 1;
- int do_vm = 0; /* Default to 1 fork, 1 chunk of 256MB. */
- long long do_vm_forks = 1;
- long long do_vm_chunks = 1;
- long long do_vm_bytes = 256 * 1024 * 1024;
- int do_hdd = 0; /* Default to 1 fork, clean, 1 file of 1GB. */
- long long do_hdd_forks = 1;
- int do_hdd_clean = 0;
- long long do_hdd_files = 1;
- long long do_hdd_bytes = 1024 * 1024 * 1024;
-
- /* Record our start time. */
- if ((starttime = time(NULL)) == -1) {
- err(stderr, "failed to acquire current time\n");
- exit(1);
- }
-
- /* SuSv3 does not define any error conditions for this function. */
- global_progname = basename(argv[0]);
-
- /* For portability, parse command line options without getopt_long. */
- for (i = 1; i < argc; i++) {
- char *arg = argv[i];
-
- if (strcmp(arg, "--help") == 0 || strcmp(arg, "-?") == 0) {
- usage(0);
- } else if (strcmp(arg, "--version") == 0) {
- version(0);
- } else if (strcmp(arg, "--verbose") == 0
- || strcmp(arg, "-v") == 0) {
- global_debug = 3;
- } else if (strcmp(arg, "--quiet") == 0
- || strcmp(arg, "-q") == 0) {
- global_debug = 0;
- } else if (strcmp(arg, "--dry-run") == 0
- || strcmp(arg, "-n") == 0) {
- do_dryrun = 1;
- } else if (strcmp(arg, "--no-retry") == 0) {
- global_ignore = 0;
- dbg(stdout,
- "turning off ignore of non-critical errors");
- } else if (strcmp(arg, "--retry-delay") == 0) {
- assert_arg("--retry-delay");
- global_retry = atoll(arg);
- dbg(stdout, "setting retry delay to %dus\n",
- global_retry);
- } else if (strcmp(arg, "--backoff") == 0) {
- assert_arg("--backoff");
- global_backoff = atoll(arg);
- if (global_backoff < 0) {
- err(stderr, "invalid backoff factor: %i\n",
- global_backoff);
- exit(1);
- }
- dbg(stdout, "setting backoff coeffient to %dus\n",
- global_backoff);
- } else if (strcmp(arg, "--timeout") == 0
- || strcmp(arg, "-t") == 0) {
- do_timeout = 1;
- assert_arg("--timeout");
- global_timeout = atoll_s(arg);
- dbg(stdout, "setting timeout to %ds\n", global_timeout);
- } else if (strcmp(arg, "--cpu") == 0 || strcmp(arg, "-c") == 0) {
- do_cpu = 1;
- assert_arg("--cpu");
- do_cpu_forks = atoll_b(arg);
- } else if (strcmp(arg, "--io") == 0 || strcmp(arg, "-i") == 0) {
- do_io = 1;
- assert_arg("--io");
- do_io_forks = atoll_b(arg);
- } else if (strcmp(arg, "--vm") == 0 || strcmp(arg, "-m") == 0) {
- do_vm = 1;
- assert_arg("--vm");
- do_vm_forks = atoll_b(arg);
- } else if (strcmp(arg, "--vm-chunks") == 0) {
- assert_arg("--vm-chunks");
- do_vm_chunks = atoll_b(arg);
- } else if (strcmp(arg, "--vm-bytes") == 0) {
- assert_arg("--vm-bytes");
- do_vm_bytes = atoll_b(arg);
- } else if (strcmp(arg, "--vm-hang") == 0) {
- global_vmhang = 1;
- } else if (strcmp(arg, "--hdd") == 0 || strcmp(arg, "-d") == 0) {
- do_hdd = 1;
- assert_arg("--hdd");
- do_hdd_forks = atoll_b(arg);
- } else if (strcmp(arg, "--hdd-noclean") == 0) {
- do_hdd_clean = 2;
- } else if (strcmp(arg, "--hdd-files") == 0) {
- assert_arg("--hdd-files");
- do_hdd_files = atoll_b(arg);
- } else if (strcmp(arg, "--hdd-bytes") == 0) {
- assert_arg("--hdd-bytes");
- do_hdd_bytes = atoll_b(arg);
- } else {
- err(stderr, "unrecognized option: %s\n", arg);
- exit(1);
- }
- }
-
- /* Hog CPU option. */
- if (do_cpu) {
- out(stdout, "dispatching %lli hogcpu forks\n", do_cpu_forks);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogcpu(do_cpu_forks));
- case -1: /* error */
- err(stderr, "hogcpu dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogcpu dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog I/O option. */
- if (do_io) {
- out(stdout, "dispatching %lli hogio forks\n", do_io_forks);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogio(do_io_forks));
- case -1: /* error */
- err(stderr, "hogio dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogio dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog VM option. */
- if (do_vm) {
- out(stdout,
- "dispatching %lli hogvm forks, each %lli chunks of %lli bytes\n",
- do_vm_forks, do_vm_chunks, do_vm_bytes);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hogvm(do_vm_forks, do_vm_chunks, do_vm_bytes));
- case -1: /* error */
- err(stderr, "hogvm dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hogvm dispatcher forked (%i)\n", pid);
- }
- }
-
- /* Hog HDD option. */
- if (do_hdd) {
- out(stdout, "dispatching %lli hoghdd forks, each %lli files of "
- "%lli bytes\n", do_hdd_forks, do_hdd_files, do_hdd_bytes);
-
- switch (pid = fork()) {
- case 0: /* child */
- if (do_dryrun)
- exit(0);
- exit(hoghdd
- (do_hdd_forks, do_hdd_clean, do_hdd_files,
- do_hdd_bytes));
- case -1: /* error */
- err(stderr, "hoghdd dispatcher fork failed\n");
- exit(1);
- default: /* parent */
- children++;
- dbg(stdout, "--> hoghdd dispatcher forked (%i)\n", pid);
- }
- }
-
- /* We have no work to do, so bail out. */
- if (children == 0)
- usage(0);
-
- /* Wait for our children to exit. */
- while (children) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "dispatcher %i returned error %i\n",
- pid, ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- dispatcher return (%i)\n",
- pid);
- }
- } else {
- err(stderr,
- "dispatcher did not exit normally\n");
- ++retval;
- }
-
- --children;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing dispatcher children\n");
- ++retval;
- break;
- }
- }
-
- /* Record our stop time. */
- if ((stoptime = time(NULL)) == -1) {
- err(stderr, "failed to acquire current time\n");
- exit(1);
- }
-
- /* Calculate our runtime. */
- runtime = stoptime - starttime;
-
- /* Print final status message. */
- if (retval) {
- err(stderr, "failed run completed in %lis\n", runtime);
- } else {
- out(stdout, "successful run completed in %lis\n", runtime);
- }
-
- exit(retval);
-}
-
-int usage(int status)
-{
- char *mesg =
- "`%s' imposes certain types of compute stress on your system\n\n"
- "Usage: %s [OPTION [ARG]] ...\n\n"
- " -?, --help show this help statement\n"
- " --version show version statement\n"
- " -v, --verbose be verbose\n"
- " -q, --quiet be quiet\n"
- " -n, --dry-run show what would have been done\n"
- " --no-retry exit rather than retry non-critical errors\n"
- " --retry-delay n wait n us before continuing past error\n"
- " -t, --timeout n timeout after n seconds\n"
- " --backoff n wait for factor of n us before starting work\n"
- " -c, --cpu n spawn n procs spinning on sqrt()\n"
- " -i, --io n spawn n procs spinning on sync()\n"
- " -m, --vm n spawn n procs spinning on malloc()\n"
- " --vm-chunks c malloc c chunks (default is 1)\n"
- " --vm-bytes b malloc chunks of b bytes (default is 256MB)\n"
- " --vm-hang hang in a sleep loop after memory allocated\n"
- " -d, --hdd n spawn n procs spinning on write()\n"
- " --hdd-noclean do not unlink file to which random data written\n"
- " --hdd-files f write to f files (default is 1)\n"
- " --hdd-bytes b write b bytes (default is 1GB)\n\n"
- "Infinity is denoted with 0. For -m, -d: n=0 means infinite redo,\n"
- "n<0 means redo abs(n) times. Valid suffixes are m,h,d,y for time;\n"
- "k,m,g for size.\n\n";
-
- fprintf(stdout, mesg, global_progname, global_progname);
-
- if (status <= 0)
- exit(-1 * status);
-
- return 0;
-}
-
-int version(int status)
-{
- char *mesg = "%s %s\n";
-
- fprintf(stdout, mesg, global_progname, VERSION);
-
- if (status <= 0)
- exit(-1 * status);
-
- return 0;
-}
-
-/* Convert a string representation of a number with an optional size suffix
- * to a long long.
- */
-long long atoll_b(const char *nptr)
-{
- int pos;
- char suffix;
- long long factor = 1;
-
- if ((pos = strlen(nptr) - 1) < 0) {
- err(stderr, "invalid string\n");
- exit(1);
- }
-
- switch (suffix = nptr[pos]) {
- case 'k':
- case 'K':
- factor = 1024;
- break;
- case 'm':
- case 'M':
- factor = 1024 * 1024;
- break;
- case 'g':
- case 'G':
- factor = 1024 * 1024 * 1024;
- break;
- default:
- if (suffix < '0' || suffix > '9') {
- err(stderr, "unrecognized suffix: %c\n", suffix);
- exit(1);
- }
- }
-
- factor = atoll(nptr) * factor;
-
- return factor;
-}
-
-/* Convert a string representation of a number with an optional time suffix
- * to a long long.
- */
-long long atoll_s(const char *nptr)
-{
- int pos;
- char suffix;
- long long factor = 1;
-
- if ((pos = strlen(nptr) - 1) < 0) {
- err(stderr, "invalid string\n");
- exit(1);
- }
-
- switch (suffix = nptr[pos]) {
- case 's':
- case 'S':
- factor = 1;
- break;
- case 'm':
- case 'M':
- factor = 60;
- break;
- case 'h':
- case 'H':
- factor = 60 * 60;
- break;
- case 'd':
- case 'D':
- factor = 60 * 60 * 24;
- break;
- case 'y':
- case 'Y':
- factor = 60 * 60 * 24 * 360;
- break;
- default:
- if (suffix < '0' || suffix > '9') {
- err(stderr, "unrecognized suffix: %c\n", suffix);
- exit(1);
- }
- }
-
- factor = atoll(nptr) * factor;
-
- return factor;
-}
-
-int hogcpu(long long forks)
-{
- long long i;
- double d;
- int pid, retval = 0;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogcpu\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1)
- d = sqrt(rand());
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogcpu worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogcpu worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogcpu worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogcpu worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogcpu worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout,
- "<-- hogcpu worker signalled (%i)\n", pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr,
- "detected missing hogcpu worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hogio(long long forks)
-{
- long long i;
- int pid, retval = 0;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogio\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1)
- sync();
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogio worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogio worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogio worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogio worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogio worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout, "<-- hogio worker signalled (%i)\n",
- pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing hogio worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hogvm(long long forks, long long chunks, long long bytes)
-{
- long long i, j, k;
- int pid, retval = 0;
- char **ptr;
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- dbg(stdout, "using backoff sleep of %lius for hogvm\n", backoff);
-
- if (bytes == 0) {
- /* 512MB is guess at the largest value can than be malloced at once. */
- bytes = 512 * 1024 * 1024;
- }
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- /* If chunks is 0, ptr will allocate 0 bytes's
- * memory, it will cause the process to crash
- * during runtime, so adjust to 1 */
- if (chunks == 0)
- chunks = 1;
-
- while (1) {
- ptr = (char **)malloc(chunks *
- sizeof(char *));
- for (j = 0; j < chunks; j++) {
- if ((ptr[j] =
- (char *)malloc(bytes *
- sizeof(char)))) {
- for (k = 0; k < bytes; k++)
- ptr[j][k] = 'Z'; /* Ensure that COW happens. */
- dbg(stdout,
- "hogvm worker malloced %lli bytes\n",
- k);
- } else if (ignore) {
- ++retval;
- wrn(stderr,
- "hogvm malloc failed, continuing\n");
- usleep(retry);
- continue;
- } else {
- ++retval;
- err(stderr,
- "hogvm malloc failed\n");
- break;
- }
- }
- if (global_vmhang && retval == 0) {
- dbg(stdout,
- "sleeping forever with allocated memory\n");
- while (1)
- sleep(1024);
- }
- if (retval == 0) {
- dbg(stdout,
- "hogvm worker freeing memory and starting over\n");
- for (j = 0; j < chunks; j++)
- free(ptr[j]);
- free(ptr);
- continue;
- }
-
- exit(retval);
- }
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hogvm worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hogvm worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hogvm worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hogvm worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hogvm worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout, "<-- hogvm worker signalled (%i)\n",
- pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr, "detected missing hogvm worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
-
-int hoghdd(long long forks, int clean, long long files, long long bytes)
-{
- long long i, j;
- int fd, pid, retval = 0;
- int chunk = (1024 * 1024) - 1; /* Minimize slow writing. */
- char buff[chunk];
-
- /* Make local copies of global variables. */
- int ignore = global_ignore;
- int retry = global_retry;
- int timeout = global_timeout;
- long backoff = global_backoff * forks;
-
- /* Initialize buffer with some random ASCII data. */
- dbg(stdout, "seeding buffer with random data\n");
- for (i = 0; i < chunk - 1; i++) {
- j = rand();
- j = (j < 0) ? -j : j;
- j %= 95;
- j += 32;
- buff[i] = j;
- }
- buff[i] = '\n';
-
- dbg(stdout, "using backoff sleep of %lius for hoghdd\n", backoff);
-
- for (i = 0; forks == 0 || i < forks; i++) {
- switch (pid = fork()) {
- case 0: /* child */
- alarm(timeout);
-
- /* Use a backoff sleep to ensure we get good fork throughput. */
- usleep(backoff);
-
- while (1) {
- for (i = 0; i < files; i++) {
- char name[] = "./stress.XXXXXX";
-
- if ((fd = mkstemp(name)) < 0) {
- perror("mkstemp");
- err(stderr, "mkstemp failed\n");
- exit(1);
- }
-
- if (clean == 0) {
- dbg(stdout, "unlinking %s\n",
- name);
- if (unlink(name)) {
- err(stderr,
- "unlink failed\n");
- exit(1);
- }
- }
-
- dbg(stdout, "fast writing to %s\n",
- name);
- for (j = 0;
- bytes == 0 || j + chunk < bytes;
- j += chunk) {
- if (write(fd, buff, chunk) !=
- chunk) {
- err(stderr,
- "write failed\n");
- exit(1);
- }
- }
-
- dbg(stdout, "slow writing to %s\n",
- name);
- for (; bytes == 0 || j < bytes - 1; j++) {
- if (write(fd, "Z", 1) != 1) {
- err(stderr,
- "write failed\n");
- exit(1);
- }
- }
- if (write(fd, "\n", 1) != 1) {
- err(stderr, "write failed\n");
- exit(1);
- }
- ++j;
-
- dbg(stdout,
- "closing %s after writing %lli bytes\n",
- name, j);
- close(fd);
-
- if (clean == 1) {
- if (unlink(name)) {
- err(stderr,
- "unlink failed\n");
- exit(1);
- }
- }
- }
- if (retval == 0) {
- dbg(stdout,
- "hoghdd worker starting over\n");
- continue;
- }
-
- exit(retval);
- }
-
- /* This case never falls through; alarm signal can cause exit. */
- case -1: /* error */
- if (ignore) {
- ++retval;
- wrn(stderr,
- "hoghdd worker fork failed, continuing\n");
- usleep(retry);
- continue;
- }
-
- err(stderr, "hoghdd worker fork failed\n");
- return 1;
- default: /* parent */
- dbg(stdout, "--> hoghdd worker forked (%i)\n", pid);
- }
- }
-
- /* Wait for our children to exit. */
- while (i) {
- int status, ret;
-
- if ((pid = wait(&status)) > 0) {
- if ((WIFEXITED(status)) != 0) {
- if ((ret = WEXITSTATUS(status)) != 0) {
- err(stderr,
- "hoghdd worker %i exited %i\n", pid,
- ret);
- retval += ret;
- } else {
- dbg(stdout,
- "<-- hoghdd worker exited (%i)\n",
- pid);
- }
- } else {
- dbg(stdout,
- "<-- hoghdd worker signalled (%i)\n", pid);
- }
-
- --i;
- } else {
- dbg(stdout, "wait() returned error: %s\n",
- strerror(errno));
- err(stderr,
- "detected missing hoghdd worker children\n");
- ++retval;
- break;
- }
- }
-
- return retval;
-}
diff --git a/tools/html_report_header.txt b/tools/html_report_header.txt
deleted file mode 100644
index b3da2c5441..0000000000
--- a/tools/html_report_header.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
-<head>
- <title>Linux Test Project - Results</title>
-</head>
-<body>
-
-<h1>LTP Output/Log </h1>
-<table border="1" cellspacing="3">
- <tbody>
- <tr>
- <td bgcolor="#66ff66"><b> PASSED </b></td>
- <td bgcolor="#ff0000"><b> FAILED </b></td>
- <td bgcolor="Fuchsia"><b> WARNING </b></td>
- <td bgcolor="Yellow"><b> BROKEN </b></td>
- <td bgcolor="#8dc997"><b> RETIRED </b></td>
- <td bgcolor="Aqua"><b> CONFIG-ERROR </b></td>
- </tr>
- </tbody>
-</table>
-<br>
-<b>Meaning of the following KEYWORDS in test results/logs:</b>
-<hr>
-<li><b>TPASS -</b> Indicates that the test case had the expected result and passed</li>
-<li><b>TFAIL -</b> Indicates that the test case had an unexpected result and failed.</li>
-<li><b>TBROK -</b> Indicates that the remaining test cases are broken and will not execute correctly, because some precondition not met, such as a resource not being available.</li>
-<li><b>TCONF -</b> Indicates that the test case was not written to run on the current harware or software configuration such as machine type, or, kernel version.</li>
-<li><b>TWARN -</b> Indicates that the test case experienced an unexpected or undesirable event that should not affect the test itself such as being unable to cleanup resources after the test finished.</li>
-<li><b>TINFO -</b> Specifies useful information about the status of the test that does not affect the result and does not indicate a problem.</li>
-<hr>
-
-<br>
-<li><a href="#_1">Click Here for Detailed Report</a></li>
-<li><a href="#_2">Click Here for Summary Report</a></li>
-<br>
-
-<h2 id="_1">Detailed Report</h2>
-<div>
-<table border="1" cellspacing="3">
-<tbody>
- <tr>
- <td bgcolor="Silver"><strong>No</strong></td>
- <td bgcolor="Silver"><strong>Test-Name</strong></td>
- <td bgcolor="Silver"><strong>Start-Time</strong></td>
- <td bgcolor="Silver"><strong>Command-Line</strong></td>
- <td bgcolor="Silver"><strong>Contacts</strong></td>
- <td bgcolor="Silver"><strong>Analysis</strong></td>
- <td bgcolor="Silver"><strong>Test-Output</strong></td>
- <td bgcolor="Silver"><strong>Initiation-Status</strong></td>
- <td bgcolor="Silver"><strong>Duration</strong></td>
- <td bgcolor="Silver"><strong>Termination-type</strong></td>
- <td bgcolor="Silver"><strong>Termination-id</strong></td>
- <td bgcolor="Silver"><strong>Core-File</strong></td>
- <td bgcolor="Silver"><strong>cutime</strong></td>
- <td bgcolor="Silver"><strong>cstime</strong></td>
- </tr>
diff --git a/tools/insert_kernel_faults.sh b/tools/insert_kernel_faults.sh
deleted file mode 100755
index ae24ae108f..0000000000
--- a/tools/insert_kernel_faults.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2009 ##
-## ##
-## This program is free software; you can redistribute it and/or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-################################################################################
-# ##
-# File : insert_kernel_faults.sh ##
-# ##
-# Usage: insert_kernel_faults.sh <fault_percentage> ##
-# ##
-# Description: This is a simple script that inserts faults at various ##
-# subsystems of the kernel. Please refer to the ltp/README ##
-# for the various kernel CONFIG options needed to exploit ##
-# all those features ##
-# ##
-# Author: Subrata Modak <subrata@linux.vnet.ibm.com> ##
-# ##
-# History: Aug 11 2009 - Created - Subrata Modak. ##
-# Aug 17 2009 - Changed the debugfs mount point - Subrata Modak.##
-################################################################################
-
-if [ -z "$1" ]
- then
- #Check if Useage has been proper
- echo "Usage: $0 <fault_percentage>"
- exit 1
-fi
-
-#These are the types of Subsystems where fault will be injected
-#Make sure debugfs has been mounted
-for FAILTYPE in fail_io_timeout fail_make_request fail_page_alloc failslab
-do
- echo $1 > /sys/kernel/debug/$FAILTYPE/probability
- echo 100 > /sys/kernel/debug/$FAILTYPE/interval
- echo -1 > /sys/kernel/debug/$FAILTYPE/times
- echo 0 > /sys/kernel/debug/$FAILTYPE/space
-done
-
diff --git a/tools/restore_kernel_faults_default.sh b/tools/restore_kernel_faults_default.sh
deleted file mode 100755
index c819107bfe..0000000000
--- a/tools/restore_kernel_faults_default.sh
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/sh
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2009 ##
-## ##
-## This program is free software; you can redistribute it and/or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-################################################################################
-# ##
-# File : restore_kernel_faults_default.sh ##
-# ##
-# Usage: restore_kernel_faults_default.sh ##
-# ##
-# Description: This is a simple script that will restore the /debugfs/fail* ##
-# entries to their default values ##
-# ##
-# Author: Subrata Modak <subrata@linux.vnet.ibm.com> ##
-# ##
-# History: Aug 11 2009 - Created - Subrata Modak. ##
-# Aug 17 2009 - Changed debugfs mount point - Subrata Modak. ##
-################################################################################
-
-echo 0 > /sys/kernel/debug/fail_io_timeout/reject-end
-echo 0 > /sys/kernel/debug/fail_io_timeout/reject-start
-echo 4294967295 > /sys/kernel/debug/fail_io_timeout/require-end
-echo 0 > /sys/kernel/debug/fail_io_timeout/require-start
-echo 32 > /sys/kernel/debug/fail_io_timeout/stacktrace-depth
-echo N > /sys/kernel/debug/fail_io_timeout/task-filter
-echo 2 > /sys/kernel/debug/fail_io_timeout/verbose
-echo 0 > /sys/kernel/debug/fail_io_timeout/space
-echo 1 > /sys/kernel/debug/fail_io_timeout/times
-echo 1 > /sys/kernel/debug/fail_io_timeout/interval
-echo 0 > /sys/kernel/debug/fail_io_timeout/probability
-
-echo 0 > /sys/kernel/debug/fail_make_request/reject-end
-echo 0 > /sys/kernel/debug/fail_make_request/reject-start
-echo 4294967295 > /sys/kernel/debug/fail_make_request/require-end
-echo 0 > /sys/kernel/debug/fail_make_request/require-start
-echo 32 > /sys/kernel/debug/fail_make_request/stacktrace-depth
-echo N > /sys/kernel/debug/fail_make_request/task-filter
-echo 2 > /sys/kernel/debug/fail_make_request/verbose
-echo 0 > /sys/kernel/debug/fail_make_request/space
-echo 1 > /sys/kernel/debug/fail_make_request/times
-echo 1 > /sys/kernel/debug/fail_make_request/interval
-echo 0 > /sys/kernel/debug/fail_make_request/probability
-
-echo 1 > /sys/kernel/debug/fail_page_alloc/min-order
-echo Y > /sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem
-echo Y > /sys/kernel/debug/fail_page_alloc/ignore-gfp-wait
-echo 0 > /sys/kernel/debug/fail_page_alloc/reject-end
-echo 0 > /sys/kernel/debug/fail_page_alloc/reject-start
-echo 4294967295 > /sys/kernel/debug/fail_page_alloc/require-end
-echo 0 > /sys/kernel/debug/fail_page_alloc/require-start
-echo 32 > /sys/kernel/debug/fail_page_alloc/stacktrace-depth
-echo N > /sys/kernel/debug/fail_page_alloc/task-filter
-echo 2 > /sys/kernel/debug/fail_page_alloc/verbose
-echo 0 > /sys/kernel/debug/fail_page_alloc/space
-echo 1 > /sys/kernel/debug/fail_page_alloc/times
-echo 1 > /sys/kernel/debug/fail_page_alloc/interval
-echo 0 > /sys/kernel/debug/fail_page_alloc/probability
-
-echo Y > /sys/kernel/debug/failslab/ignore-gfp-wait
-echo 0 > /sys/kernel/debug/failslab/reject-end
-echo 0 > /sys/kernel/debug/failslab/reject-start
-echo 4294967295 > /sys/kernel/debug/failslab/require-end
-echo 0 > /sys/kernel/debug/failslab/require-start
-echo 32 > /sys/kernel/debug/failslab/stacktrace-depth
-echo N > /sys/kernel/debug/failslab/task-filter
-echo 2 > /sys/kernel/debug/failslab/verbose
-echo 0 > /sys/kernel/debug/failslab/space
-echo 1 > /sys/kernel/debug/failslab/times
-echo 1 > /sys/kernel/debug/failslab/interval
-echo 0 > /sys/kernel/debug/failslab/probability
-
--
2.51.0
More information about the ltp
mailing list