Commit 6e1956f2 authored by Philip Carns's avatar Philip Carns
Browse files

test case for bulk write

parent a20c6eff
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "abt.h" #include "abt.h"
#include "abt-snoozer.h" #include "abt-snoozer.h"
...@@ -19,11 +23,36 @@ int main(int argc, char **argv) ...@@ -19,11 +23,36 @@ int main(int argc, char **argv)
int ret; int ret;
bake_target_id_t bti; bake_target_id_t bti;
bake_bulk_region_id_t rid; bake_bulk_region_id_t rid;
int fd;
struct stat statbuf;
char* local_region;
if(argc != 2) if(argc != 3)
{ {
fprintf(stderr, "Usage: bb-copy-to <server addr>\n"); fprintf(stderr, "Usage: bb-copy-to <local file> <server addr>\n");
fprintf(stderr, " Example: ./bb-copy-to tcp://localhost:1234\n"); fprintf(stderr, " Example: ./bb-copy-to /tmp/foo.dat tcp://localhost:1234\n");
return(-1);
}
fd = open(argv[1], O_RDONLY);
if(fd < 0)
{
perror("open");
return(-1);
}
ret = fstat(fd, &statbuf);
if(ret < 0)
{
perror("fstat");
close(fd);
return(-1);
}
local_region = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if(!local_region)
{
perror("mmap");
close(fd);
return(-1); return(-1);
} }
...@@ -31,39 +60,65 @@ int main(int argc, char **argv) ...@@ -31,39 +60,65 @@ int main(int argc, char **argv)
ret = ABT_init(argc, argv); ret = ABT_init(argc, argv);
if(ret != 0) if(ret != 0)
{ {
munmap(local_region, statbuf.st_size);
close(fd);
fprintf(stderr, "Error: ABT_init()\n"); fprintf(stderr, "Error: ABT_init()\n");
return(-1); return(-1);
} }
ret = ABT_snoozer_xstream_self_set(); ret = ABT_snoozer_xstream_self_set();
if(ret != 0) if(ret != 0)
{ {
ABT_finalize();
munmap(local_region, statbuf.st_size);
close(fd);
fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n"); fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
return(-1); return(-1);
} }
ret = bake_probe_instance(argv[1], &bti); ret = bake_probe_instance(argv[2], &bti);
if(ret < 0) if(ret < 0)
{ {
ABT_finalize();
munmap(local_region, statbuf.st_size);
close(fd);
fprintf(stderr, "Error: bake_probe_instance()\n"); fprintf(stderr, "Error: bake_probe_instance()\n");
return(-1); return(-1);
} }
/* TODO: find local file, check it's size */ /* create region */
ret = bake_bulk_create(bti, statbuf.st_size, &rid);
/* TODO: create appropriate size region */
ret = bake_bulk_create(bti, 1024, &rid);
if(ret != 0) if(ret != 0)
{ {
bake_release_instance(bti);
ABT_finalize();
munmap(local_region, statbuf.st_size);
close(fd);
fprintf(stderr, "Error: bake_bulk_create()\n"); fprintf(stderr, "Error: bake_bulk_create()\n");
return(-1); return(-1);
} }
/* TODO: a way to print region id */ /* TODO: a way to print region id */
/* TODO: data transfer */ /* transfer data */
ret = bake_bulk_write(
bti,
rid,
0,
local_region,
statbuf.st_size);
if(ret != 0)
{
bake_release_instance(bti); bake_release_instance(bti);
ABT_finalize();
munmap(local_region, statbuf.st_size);
close(fd);
fprintf(stderr, "Error: bake_bulk_write()\n");
return(-1);
}
munmap(local_region, statbuf.st_size);
close(fd);
bake_release_instance(bti);
ABT_finalize(); ABT_finalize();
return(0); return(0);
......
...@@ -12,12 +12,14 @@ test_start_servers 1 2 20 ...@@ -12,12 +12,14 @@ test_start_servers 1 2 20
# actual test case # actual test case
##################### #####################
run_to 10 src/bb-copy-to $svr1 echo "Hello world." > $TMPBASE/foo.dat
run_to 10 src/bb-copy-to $TMPBASE/foo.dat $svr1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
run_to 10 src/bb-shutdown $svr1 &> /dev/null run_to 10 src/bb-shutdown $svr1 &> /dev/null
wait wait
exit 1 exit 1
fi fi
sleep 1 sleep 1
##################### #####################
......
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