Commit a61ebca2 authored by Glenn K. Lockwood's avatar Glenn K. Lockwood

added some infrastructure to facilitate unit testing of the darshan lustre module

parent a2a9e135
.PHONY: clean
BINS = darshan-tester darshan-tester-mpi
OBJS = darshan-core-stub.o darshan-lustre.o
CFLAGS = -O0 -g -I../.. -I../../darshan-runtime
### Include -I. when building non-MPI tests to include the mpi.h stub header
CFLAGS += -I.
darshan-tester: $(OBJS)
$(CC) $(LDFLAGS) $? $(LOADLIBES) $(LDLIBS) -o $@
darshan-tester-mpi: $(OBJS)
$(CC) $(LDFLAGS) $? $(LOADLIBES) $(LDLIBS) -o $@
darshan-lustre.o: ../../darshan-runtime/lib/darshan-lustre.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $? -o $@
clean:
-@rm -v $(OBJS) $(BINS)
#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
#include "darshan-runtime-config.h"
#include "darshan.h"
#include "darshan-core.h"
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
/*
* Global variables
*/
static darshan_record_id next_rec_id = 0;
static int my_rank = 0;
static struct darshan_module_funcs mod_funcs;
/*
* Import routines from Lustre module
*/
void darshan_core_register_record(
void *name,
int len,
darshan_module_id mod_id,
int printable_flag,
int mod_limit_flag,
darshan_record_id *rec_id,
struct darshan_fs_info *fs_info)
{
*rec_id = next_rec_id++;
if (fs_info)
{
memset( fs_info, 0, sizeof(struct darshan_fs_info) );
fs_info->fs_type = -1;
}
return;
}
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
int *rank,
int *mod_mem_limit,
int *sys_mem_alignment)
{
/* if (sys_mem_alignment) *sys_mem_alignment = darshan_mem_alignment; */
if (rank) *rank = my_rank;
*mod_mem_limit = DARSHAN_MOD_MEM_MAX;
mod_funcs = *funcs;
return;
}
void darshan_core_shutdown()
{
darshan_record_id *mod_shared_recs = NULL;
int mod_shared_rec_cnt = 0;
void* mod_buf = NULL;
int mod_buf_sz = 0;
mod_funcs.begin_shutdown();
mod_funcs.get_output_data( MPI_COMM_WORLD, mod_shared_recs, mod_shared_rec_cnt, &mod_buf, &mod_buf_sz );
print_lustre_runtime();
mod_funcs.shutdown();
return;
}
int main( int argc, char **argv )
{
int fd, i;
char *fname;
srand(234);
/* build Darshan records */
for ( i = 1; i < argc; i++ )
{
fname = argv[i];
printf( "\nProcessing %s\n", fname );
fd = open( fname, O_RDONLY );
darshan_instrument_lustre_file( fname, fd );
close(fd);
}
print_lustre_runtime();
darshan_core_shutdown();
return 0;
}
/*
* VERY primitive stubs that allow darshan.h to be included in non-MPI
* applications like darshan-tester
*/
typedef int MPI_Comm;
typedef int MPI_Datatype;
typedef int MPI_Op;
#define MPI_COMM_WORLD 0
#!/bin/bash
#
# Run the test program through Valgrind to expose memory leaks and buffer
# overflows on a variety of different file locations and geometries
#
### Make some files to test. Assume $SCRATCH points at Lustre
for stripe in 1 2 4 8 16 32
do
if [ ! -f $SCRATCH/stripe${stripe} ]; then
lfs setstripe -c $stripe $SCRATCH/stripe${stripe}
fi
done
set -x
valgrind --tool=memcheck \
--leak-check=yes \
--show-reachable=yes \
--num-callers=20 \
--track-fds=yes \
--read-var-info=yes \
./darshan-tester \
$SCRATCH/stripe4 \
$SCRATCH/stripe32 \
$SCRATCH/stripe1 \
$SCRATCH/stripe16 \
$SCRATCH/stripe8 \
$HOME/.bashrc \
$SCRATCH/stripe2
set +x
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment