summaryrefslogtreecommitdiffabout
path: root/tests/lines.c
authorSergey Poznyakoff <gray@gnu.org>2019-06-02 08:57:42 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-06-02 08:57:42 (GMT)
commit685600d72b0c300f94c0c69dc0a16c4ebb230a21 (patch) (side-by-side diff)
tree3a3ea6f43a8cdc543118e2cf81d29628dc82f61f /tests/lines.c
parentcc298a11a131b162f291d6ee27ba1d7598a1b6c4 (diff)
downloadpies-685600d72b0c300f94c0c69dc0a16c4ebb230a21.tar.gz
pies-685600d72b0c300f94c0c69dc0a16c4ebb230a21.tar.bz2
Rewrite the testsuite
The aim is to run pies in foreground if possible. Limit execution time using external wrapper. * src/pies.c: (_cb_redir): Consistently return 1 on errors. * tests/aux/sleepexit: New file. * tests/aux/startcheck: New file. * tests/aux/touchfile: Change arguments. * tests/aux/respawn: Rewrite. * tests/lines.c: New noinst program. * tests/to.c: New noinst program. * tests/.gitignore: Add new programs. * tests/Makefile.am: Update. * tests/env.at: Use to to avoid hanging forever. Add missing popdef. * tests/redirect.at: Use echo as component program. * tests/respawn.at: Run pies in foreground. Use to to limit execution time. * tests/shell.at: Likewise. * tests/shutdown.at: Likewise. * tests/startup.at: Likewise. * tests/ret-exec.at: Use sleepexit as component program. * tests/ret-notify.at: Likewise.
Diffstat (limited to 'tests/lines.c') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/lines.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lines.c b/tests/lines.c
new file mode 100644
index 0000000..106491f
--- a/dev/null
+++ b/tests/lines.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+ char *progname = argv[0];
+ FILE *fp;
+ int c;
+ unsigned count;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "usage: %s FILE\n", progname);
+ return 1;
+ }
+
+ fp = fopen (argv[1], "r");
+ if (!fp)
+ {
+ perror (argv[1]);
+ return 2;
+ }
+
+ count = 0;
+ while ((c = fgetc (fp)) != EOF)
+ if (c == '\n')
+ count++;
+ fclose (fp);
+ printf ("%u\n", count);
+ return 0;
+}

Return to:

Send suggestions and report system problems to the System administrator.