Skip to content

Commit ac7600d

Browse files
committed
Unit-test with automake for library version. Minor fix for library version.
1 parent 5ef9567 commit ac7600d

File tree

9 files changed

+90
-66
lines changed

9 files changed

+90
-66
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ See also NOTES.txt
2424

2525
# Testing
2626

27+
Run "make check" to invoke the unit test framework of Automake.
28+
2729
* To run basic functionality tests that we use for continuous integration, see ./testing/
2830
* There are docker scripts provided to test various distributions at once.
2931
* See ./testing/docker/

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ AX_PROG_CC_MPI(,,[
2626
AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
2727
])
2828

29+
AC_PROG_RANLIB
2930
# No reason not to require modern C at this point
3031
AC_PROG_CC_C99
3132

@@ -244,5 +245,6 @@ AM_CONDITIONAL([USE_CAPS], [test x$enable_caps = xyes])
244245
AC_CONFIG_FILES([Makefile
245246
src/Makefile
246247
contrib/Makefile
248+
src/test/Makefile
247249
doc/Makefile])
248250
AC_OUTPUT

src/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
SUBDIRS = . test
2+
13
bin_PROGRAMS = ior mdtest
24
if USE_CAPS
35
bin_PROGRAMS += IOR MDTEST
46
endif
57

68
noinst_HEADERS = ior.h utilities.h parse_options.h aiori.h iordef.h ior-internal.h option.h
79

10+
lib_LIBRARIES = libaiori.a
11+
libaiori_a_SOURCES = ior.c mdtest.c utilities.c parse_options.c ior-output.c option.c
12+
813
extraSOURCES = aiori.c aiori-DUMMY.c
914
extraLDADD =
1015
extraLDFLAGS =
@@ -88,3 +93,5 @@ IOT_CPPFLAGS = $(ior_CPPFLAGS)
8893
MDTEST_SOURCES = $(mdtest_SOURCES)
8994
MDTEST_LDADD = $(mdtest_LDADD)
9095
MDTEST_CPPFLAGS = $(mdtest_CPPFLAGS)
96+
97+
libaiori_a_SOURCES += $(extraSOURCES)

src/aiori-S3.c

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,39 @@
110110
#include "aws4c_extra.h" // utilities, e.g. for parsing XML in responses
111111

112112

113+
114+
115+
/* buffer is used to generate URLs, err_msgs, etc */
116+
#define BUFF_SIZE 1024
117+
static char buff[BUFF_SIZE];
118+
119+
const int ETAG_SIZE = 32;
120+
121+
CURLcode rc;
122+
123+
/* Any objects we create or delete will be under this bucket */
124+
const char* bucket_name = "ior";
125+
126+
/* TODO: The following stuff goes into options! */
127+
/* REST/S3 variables */
128+
// CURL* curl; /* for libcurl "easy" fns (now managed by aws4c) */
129+
# define IOR_CURL_INIT 0x01 /* curl top-level inits were perfomed once? */
130+
# define IOR_CURL_NOCONTINUE 0x02
131+
# define IOR_CURL_S3_EMC_EXT 0x04 /* allow EMC extensions to S3? */
132+
133+
#ifdef USE_S3_AIORI
134+
# include <curl/curl.h>
135+
# include "aws4c.h"
136+
#else
137+
typedef void CURL; /* unused, but needs a type */
138+
typedef void IOBuf; /* unused, but needs a type */
139+
#endif
140+
141+
IOBuf* io_buf; /* aws4c places parsed header values here */
142+
IOBuf* etags; /* accumulate ETags for N:1 parts */
143+
144+
///////////////////////////////////////////////
145+
113146
/**************************** P R O T O T Y P E S *****************************/
114147
static void* S3_Create(char*, IOR_param_t*);
115148
static void* S3_Open(char*, IOR_param_t*);
@@ -180,17 +213,23 @@ ior_aiori_t s3_emc_aiori = {
180213
.finalize = S3_finalize
181214
};
182215

216+
static int is_initialized = FALSE;
217+
183218
static void S3_init(){
184-
/* This is supposed to be done before *any* threads are created.
185-
* Could MPI_Init() create threads (or call multi-threaded
186-
* libraries)? We'll assume so. */
187-
AWS4C_CHECK( aws_init() );
219+
if (is_initialized) return;
220+
is_initialized = TRUE;
221+
/* This is supposed to be done before *any* threads are created.
222+
* Could MPI_Init() create threads (or call multi-threaded
223+
* libraries)? We'll assume so. */
224+
AWS4C_CHECK( aws_init() );
188225
}
189226

190227
static void S3_finalize(){
191-
/* done once per program, after exiting all threads.
192-
* NOTE: This fn doesn't return a value that can be checked for success. */
193-
aws_cleanup();
228+
if (! is_initialized) return;
229+
is_initialized = FALSE;
230+
/* done once per program, after exiting all threads.
231+
* NOTE: This fn doesn't return a value that can be checked for success. */
232+
aws_cleanup();
194233
}
195234

196235
/* modelled on similar macros in iordef.h */
@@ -213,20 +252,6 @@ static void S3_finalize(){
213252
} while (0)
214253

215254

216-
217-
/* buffer is used to generate URLs, err_msgs, etc */
218-
#define BUFF_SIZE 1024
219-
static char buff[BUFF_SIZE];
220-
221-
const int ETAG_SIZE = 32;
222-
223-
CURLcode rc;
224-
225-
/* Any objects we create or delete will be under this bucket */
226-
const char* bucket_name = "ior";
227-
//const char* bucket_name = "brettk";
228-
229-
230255
/***************************** F U N C T I O N S ******************************/
231256

232257

@@ -251,9 +276,8 @@ const char* bucket_name = "ior";
251276
* ---------------------------------------------------------------------------
252277
*/
253278

254-
static
255-
void
256-
s3_connect( IOR_param_t* param ) {
279+
280+
static void s3_connect( IOR_param_t* param ) {
257281
if (param->verbose >= VERBOSE_2) {
258282
printf("-> s3_connect\n"); /* DEBUGGING */
259283
}

src/ior.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ void init_IOR_Param_t(IOR_param_t * p)
210210
p->hdfs_replicas = 0; /* invokes the default */
211211
p->hdfs_block_size = 0;
212212

213-
// p->curl = NULL;
214213
p->URI = NULL;
215-
p->curl_flags = 0;
216-
p->io_buf = NULL;
217-
p->etags = NULL;
218214
p->part_number = 0;
219215

220216
p->beegfs_numTargets = -1;
@@ -223,26 +219,6 @@ void init_IOR_Param_t(IOR_param_t * p)
223219
p->mmap_ptr = NULL;
224220
}
225221

226-
/**
227-
* Bind the global "backend" pointer to the requested backend AIORI's
228-
* function table.
229-
*/
230-
static void AioriBind(char* api, IOR_param_t* param)
231-
{
232-
backend = aiori_select (api);
233-
if (NULL != backend) {
234-
if (! strncmp(api, "S3", 2)) {
235-
if (! strcasecmp(api, "S3_EMC")) {
236-
param->curl_flags |= IOR_CURL_S3_EMC_EXT;
237-
} else {
238-
param->curl_flags &= ~(IOR_CURL_S3_EMC_EXT);
239-
}
240-
}
241-
} else {
242-
ERR("unrecognized IO API");
243-
}
244-
}
245-
246222
static void
247223
DisplayOutliers(int numTasks,
248224
double timerVal,
@@ -1235,7 +1211,7 @@ static void TestIoSys(IOR_test_t *test)
12351211
}
12361212

12371213
/* bind I/O calls to specific API */
1238-
AioriBind(params->api, params);
1214+
backend = aiori_select(params->api);
12391215

12401216
/* show test setup */
12411217
if (rank == 0 && verbose >= VERBOSE_0)

src/ior.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@
2929
typedef void* hdfsFS; /* unused, but needs a type */
3030
#endif
3131

32-
#ifdef USE_S3_AIORI
33-
# include <curl/curl.h>
34-
# include "aws4c.h"
35-
#else
36-
typedef void CURL; /* unused, but needs a type */
37-
typedef void IOBuf; /* unused, but needs a type */
38-
#endif
39-
4032
#ifdef USE_RADOS_AIORI
4133
# include <rados/librados.h>
4234
#else
@@ -180,15 +172,7 @@ typedef struct
180172
int hdfs_replicas; /* n block replicas. (0 gets default) */
181173
int hdfs_block_size; /* internal blk-size. (0 gets default) */
182174

183-
/* REST/S3 variables */
184-
// CURL* curl; /* for libcurl "easy" fns (now managed by aws4c) */
185-
# define IOR_CURL_INIT 0x01 /* curl top-level inits were perfomed once? */
186-
# define IOR_CURL_NOCONTINUE 0x02
187-
# define IOR_CURL_S3_EMC_EXT 0x04 /* allow EMC extensions to S3? */
188-
char curl_flags;
189175
char* URI; /* "path" to target object */
190-
IOBuf* io_buf; /* aws4c places parsed header values here */
191-
IOBuf* etags; /* accumulate ETags for N:1 parts */
192176
size_t part_number; /* multi-part upload increment (PER-RANK!) */
193177
char* UploadId; /* key for multi-part-uploads */
194178

src/option.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ int option_parse(int argc, char ** argv, option_help * args, int * printhelp){
267267
char * txt = argv[i];
268268
int foundOption = 0;
269269
char * arg = strstr(txt, "=");
270+
int replaced_equal = 0;
270271
if(arg != NULL){
271272
arg[0] = 0;
272273
arg++;
274+
replaced_equal = 1;
273275
}
274276
if(strcmp(txt, "--") == 0){
275277
// we found plugin options
@@ -346,7 +348,7 @@ int option_parse(int argc, char ** argv, option_help * args, int * printhelp){
346348
}
347349
}
348350
}
349-
if(arg != NULL){
351+
if(replaced_equal){
350352
arg[-1] = '=';
351353
}
352354

src/test/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TESTS = testlib
2+
bin_PROGRAMS = testlib
3+
4+
testlib_SOURCES = lib.c
5+
testlib_LDFLAGS =
6+
testlib_LDADD = ../libaiori.a
7+
testlib_CPPFLAGS =

src/test/lib.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "../ior.h"
2+
#include "../mdtest.h"
3+
4+
int main(int argc, char ** argv){
5+
int rank;
6+
MPI_Init(& argc, & argv);
7+
MPI_Comm_rank(MPI_COMM_WORLD, & rank);
8+
9+
if (rank == 0){
10+
char * param[] = {"./ior", "-a", "DUMMY"};
11+
IOR_test_t * res = ior_run(3, param, MPI_COMM_SELF, stdout);
12+
}
13+
if (rank == 0){
14+
char * param[] = {"./mdtest", "-a", "DUMMY"};
15+
mdtest_results_t * res = mdtest_run(3, param, MPI_COMM_SELF, stdout);
16+
}
17+
MPI_Finalize();
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)