[Darshan-commits] [Git][darshan/darshan][dev-stdio] stub regression test for stdio module

Philip Carns xgitlab at cels.anl.gov
Sun May 1 07:20:50 CDT 2016


Philip Carns pushed to branch dev-stdio at darshan / darshan


Commits:
76c86577 by Phil Carns at 2016-05-01T08:20:31-04:00
stub regression test for stdio module

- - - - -


3 changed files:

- darshan-runtime/lib/darshan-stdio.c
- + darshan-test/regression/test-cases/src/stdio-test.c
- + darshan-test/regression/test-cases/stdio-test.sh


Changes:

=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -421,6 +421,7 @@ static void stdio_get_output_data(
     void **stdio_buf,
     int *stdio_buf_sz)
 {
+    /* TODO: implement reduction operator */
 
     assert(stdio_runtime);
 


=====================================
darshan-test/regression/test-cases/src/stdio-test.c
=====================================
--- /dev/null
+++ b/darshan-test/regression/test-cases/src/stdio-test.c
@@ -0,0 +1,97 @@
+/*
+ * (C) 1995-2001 Clemson University and Argonne National Laboratory.
+ *
+ * See COPYING in top-level directory.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <mpi.h>
+#include <errno.h>
+#include <getopt.h>
+
+/* DEFAULT VALUES FOR OPTIONS */
+static char    opt_file[256] = "test.out";
+
+/* function prototypes */
+static int parse_args(int argc, char **argv);
+static void usage(void);
+
+/* global vars */
+static int mynod = 0;
+static int nprocs = 1;
+
+int main(int argc, char **argv)
+{
+   int namelen;
+   char processor_name[MPI_MAX_PROCESSOR_NAME];
+   FILE *file;
+
+   /* startup MPI and determine the rank of this process */
+   MPI_Init(&argc,&argv);
+   MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+   MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+   MPI_Get_processor_name(processor_name, &namelen); 
+   
+   /* parse the command line arguments */
+   parse_args(argc, argv);
+
+   if (mynod == 0) printf("# Using stdio calls.\n");
+
+   file = fopen(opt_file, "w");
+   if(!file)
+   {
+      perror("fopen");
+      return(-1);
+   }
+
+   fclose(file);
+
+   MPI_Finalize();
+   return(0);
+}
+
+static int parse_args(int argc, char **argv)
+{
+   int c;
+   
+   while ((c = getopt(argc, argv, "f:")) != EOF) {
+      switch (c) {
+         case 'f': /* filename */
+            strncpy(opt_file, optarg, 255);
+            break;
+         case '?': /* unknown */
+            if (mynod == 0)
+                usage();
+            exit(1);
+         default:
+            break;
+      }
+   }
+   return(0);
+}
+
+static void usage(void)
+{
+    printf("Usage: stdio-test [<OPTIONS>...]\n");
+    printf("\n<OPTIONS> is one of\n");
+    printf(" -f       filename [default: /foo/test.out]\n");
+    printf(" -h       print this help\n");
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 3
+ *  c-basic-offset: 3
+ *  tab-width: 3
+ *
+ * vim: ts=3
+ * End:
+ */ 
+
+


=====================================
darshan-test/regression/test-cases/stdio-test.sh
=====================================
--- /dev/null
+++ b/darshan-test/regression/test-cases/stdio-test.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+PROG=stdio-test
+
+# set log file path; remove previous log if present
+export DARSHAN_LOGFILE=$DARSHAN_TMP/${PROG}.darshan
+rm -f ${DARSHAN_LOGFILE}
+
+# compile
+$DARSHAN_CC $DARSHAN_TESTDIR/test-cases/src/${PROG}.c -o $DARSHAN_TMP/${PROG}
+if [ $? -ne 0 ]; then
+    echo "Error: failed to compile ${PROG}" 1>&2
+    exit 1
+fi
+
+# execute
+$DARSHAN_RUNJOB $DARSHAN_TMP/${PROG} -f $DARSHAN_TMP/${PROG}.tmp.dat
+if [ $? -ne 0 ]; then
+    echo "Error: failed to execute ${PROG}" 1>&2
+    exit 1
+fi
+
+# parse log
+$DARSHAN_PATH/bin/darshan-parser $DARSHAN_LOGFILE > $DARSHAN_TMP/${PROG}.darshan.txt
+if [ $? -ne 0 ]; then
+    echo "Error: failed to parse ${DARSHAN_LOGFILE}" 1>&2
+    exit 1
+fi
+
+# check results
+# in this case we want to confirm that the STDIO counters were triggered
+# TODO: change this to check aggregate counters; for now we tail -n 1 to get
+# one counter because there is no reduction operator for the stdio module yet
+STDIO_OPENS=`grep STDIO_FOPENS $DARSHAN_TMP/${PROG}.darshan.txt |tail -n 1 |cut -f 5`
+if [ ! "$STDIO_OPENS" -gt 0 ]; then
+    echo "Error: STDIO open count of $STDIO_FOPENS is incorrect" 1>&2
+    exit 1
+fi
+
+exit 0



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/76c86577231f54e29a9eace34bf026f4038f61c7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160501/d849f26c/attachment.html>


More information about the Darshan-commits mailing list