hornet-gt / hornet

Hornet data structure for sparse dynamic graphs and matrices
BSD 3-Clause "New" or "Revised" License
78 stars 31 forks source link

Check and display proper usage of example executables #51

Open rconnorlawson opened 4 years ago

rconnorlawson commented 4 years ago

Most test executables have the following command line form:

./hornet_xxx_test <graph> <batch_size>

This behavior is not documented. If you leave off the file argument, this error occurs:

HOST error
/home/rlawson6/workspace/hornet/xlib/src/Host/FileUtil.cpp(67) [ check_regular_file ]

Unable to read file

This is fairly straightforward to sort out, but it requires spelunking in the source code to figure out the command syntax.

If you leave off the batch size, however, this much more cryptic error occurs:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
[1]    10646 abort (core dumped)  ./build/hornet_insert_test ../../example/rome99.gr

Since this is an uncaught exception, getting reasonable debug info out of GDB is challenging. As a new user, I had no way of knowing if this is due to operator error (it was) or due to some instability in the library itself. After some pain I discovered that one can get a reasonable exception call stack by breaking on __ctx_throw(), an internal C++ function that begins the exception handling procedure. Only then did I realize that, in fact, I just needed to supply a batch size on the command line.

A preferable and simple behavior would be to check for the correct number of arguments before continuing, and output a usage message if incorrect. This won't catch malformatted arguments, but it at least gives new users more of a signpost.