}
+static bool speed_test_bacula(fill_mode_t mode, uint64_t nb_gb, uint32_t nb)
+{
+ DEV_BLOCK *block = dcr->block;
+ char ed1[200];
+ DEV_RECORD *rec;
+ uint64_t last_bytes = dev->VolCatInfo.VolCatBytes;
+ uint64_t written=0;
+
+ nb_gb *= 1024*1024*1024; /* convert size from nb to GB */
+
+ init_total_speed();
+
+ empty_block(block);
+ rec = new_record();
+ rec->data = check_pool_memory_size(rec->data, block->buf_len);
+ rec->data_len = block->buf_len-100;
+
+ fill_buffer(mode, rec->data, rec->data_len);
+
+ Pmsg3(0, _("Begin writing %i files of %sB with blocks of %u bytes.\n"),
+ nb, edit_uint64_with_suffix(nb_gb, ed1), block->buf_len);
+
+ for (uint32_t j=0; j<nb; j++) {
+ written = 0;
+ init_speed();
+ for ( ; written < nb_gb; ) {
+
+ if (!write_record_to_block(block, rec)) {
+ Pmsg0(0, _("\nError writing record to block.\n"));
+ goto bail_out;
+ }
+ if (!write_block_to_dev(dcr)) {
+ Pmsg0(0, _("\nError writing block to device.\n"));
+ goto bail_out;
+ }
+
+ if ((block->BlockNumber % 500) == 0) {
+ printf("+");
+ fflush(stdout);
+ }
+ written += dev->VolCatInfo.VolCatBytes - last_bytes;
+ last_bytes = dev->VolCatInfo.VolCatBytes;
+ mix_buffer(mode, rec->data, rec->data_len);
+ }
+ printf("\n");
+ weofcmd();
+ print_speed(written);
+ }
+ print_total_speed();
+ printf("\n");
+ free_record(rec);
+ return true;
+
+bail_out:
+ free_record(rec);
+ return false;
+}
+
+/* TODO: use UAContext */
+static int btape_find_arg(const char *keyword)
+{
+ for (int i=1; i<argc; i++) {
+ if (strcasecmp(keyword, argk[i]) == 0) {
+ return i;
+ }
+ }
+ return -1;
+}
+
#define ok(a) if (!(a)) return
/*
*/
static void speed_test()
{
- dev->rewind(dcr);
- Pmsg0(0, _("Test with zero data, should give the maximum throughput.\n"));
- ok(speed_test_raw(FILL_ZERO, 1, 3));
- ok(speed_test_raw(FILL_ZERO, 2, 3));
- ok(speed_test_raw(FILL_ZERO, 4, 3));
-
- Pmsg0(0, _("Test with random data, should give the minimum throughput.\n"));
- ok(speed_test_raw(FILL_RANDOM, 1, 3));
- ok(speed_test_raw(FILL_RANDOM, 2, 3));
- ok(speed_test_raw(FILL_RANDOM, 4, 3));
+ bool do_zero=true, do_random=true, do_block=true, do_raw=true;
+ uint32_t file_size=0, nb_file=3;
+ int32_t i;
+
+ i = btape_find_arg("file_size");
+ if (i > 0) {
+ file_size = atoi(argv[i]);
+ if (file_size > 100) {
+ Pmsg0(0, _("The file_size is too big, stop this test with Ctrl-c.\n"));
+ }
+ }
+
+ i = btape_find_arg("nb_file");
+ if (i > 0) {
+ nb_file = atoi(argv[i]);
+ }
+
+ if (btape_find_arg("skip_zero") > 0) {
+ do_zero = false;
+ }
+
+ if (btape_find_arg("skip_random") > 0) {
+ do_random = false;
+ }
+
+ if (btape_find_arg("skip_raw") > 0) {
+ do_raw = false;
+ }
+
+ if (btape_find_arg("skip_block") > 0) {
+ do_block = false;
+ }
+
+ if (do_raw) {
+ dev->rewind(dcr);
+ if (do_zero) {
+ Pmsg0(0, _("Test with zero data, should give the "
+ "maximum throughput.\n"));
+ if (file_size) {
+ ok(speed_test_raw(FILL_ZERO, file_size, nb_file));
+ } else {
+ ok(speed_test_raw(FILL_ZERO, 1, nb_file));
+ ok(speed_test_raw(FILL_ZERO, 2, nb_file));
+ ok(speed_test_raw(FILL_ZERO, 4, nb_file));
+ }
+ }
+
+ if (do_random) {
+ Pmsg0(0, _("Test with random data, should give the minimum "
+ "throughput.\n"));
+ if (file_size) {
+ ok(speed_test_raw(FILL_RANDOM, file_size, nb_file));
+ } else {
+ ok(speed_test_raw(FILL_RANDOM, 1, nb_file));
+ ok(speed_test_raw(FILL_RANDOM, 2, nb_file));
+ ok(speed_test_raw(FILL_RANDOM, 4, nb_file));
+ }
+ }
+ }
+
+ if (do_block) {
+ dev->rewind(dcr);
+ if (do_zero) {
+ Pmsg0(0, _("Test with zero data and bacula block structure.\n"));
+ if (file_size) {
+ ok(speed_test_bacula(FILL_ZERO, file_size, nb_file));
+ } else {
+ ok(speed_test_bacula(FILL_ZERO, 1, nb_file));
+ ok(speed_test_bacula(FILL_ZERO, 2, nb_file));
+ ok(speed_test_bacula(FILL_ZERO, 4, nb_file));
+ }
+ }
+
+ if (do_random) {
+ Pmsg0(0, _("Test with random data, should give the minimum "
+ "throughput.\n"));
+ if (file_size) {
+ ok(speed_test_bacula(FILL_RANDOM, file_size, nb_file));
+ } else {
+ ok(speed_test_bacula(FILL_RANDOM, 1, nb_file));
+ ok(speed_test_bacula(FILL_RANDOM, 2, nb_file));
+ ok(speed_test_bacula(FILL_RANDOM, 4, nb_file));
+ }
+ }
+ }
}
const int num_recs = 10000;
{NT_("rewind"), rewindcmd, _("rewind the tape")},
{NT_("scan"), scancmd, _("read() tape block by block to EOT and report")},
{NT_("scanblocks"),scan_blocks, _("Bacula read block by block to EOT and report")},
- {NT_("speed"), speed_test, _("try different configuration and report drive speed")},
+ {NT_("speed"), speed_test, _("[file_size=n(GB)|nb_file=3|skip_zero|skip_random|skip_raw|skip_block] report drive speed")},
{NT_("status"), statcmd, _("print tape status")},
{NT_("test"), testcmd, _("General test Bacula tape functions")},
{NT_("weof"), weofcmd, _("write an EOF on the tape")},