From 38d835938417b837833d739db229e7ccc87504e5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 6 Sep 2023 14:07:39 +0200 Subject: [PATCH] test/LoadDatabase: new test program (for benchmarking the database loader) --- test/LoadDatabase.cxx | 30 ++++++++++++++++++++++++++++++ test/meson.build | 15 +++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/LoadDatabase.cxx diff --git a/test/LoadDatabase.cxx b/test/LoadDatabase.cxx new file mode 100644 index 000000000..e6882118e --- /dev/null +++ b/test/LoadDatabase.cxx @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The Music Player Daemon Project + +#include "config.h" +#include "db/plugins/simple/DatabaseSave.hxx" +#include "db/plugins/simple/Directory.hxx" +#include "fs/Path.hxx" +#include "fs/NarrowPath.hxx" +#include "fs/io/TextFile.hxx" +#include "util/PrintException.hxx" + +int +main(int argc, char **argv) +try { + if (argc != 2) { + fprintf(stderr, "Usage: LoadDatabase PATH\n"); + return EXIT_FAILURE; + } + + const FromNarrowPath db_path = argv[1]; + + Directory root{{}, nullptr}; + TextFile line_reader{db_path}; + db_load_internal(line_reader, root); + + return EXIT_SUCCESS; +} catch (...) { + PrintException(std::current_exception()); + return EXIT_FAILURE; +} diff --git a/test/meson.build b/test/meson.build index f06f5ef15..387f6feed 100644 --- a/test/meson.build +++ b/test/meson.build @@ -266,6 +266,21 @@ if enable_database ], ) + executable( + 'LoadDatabase', + 'LoadDatabase.cxx', + '../src/db/PlaylistVector.cxx', + '../src/SongSave.cxx', + '../src/TagSave.cxx', + include_directories: inc, + dependencies: [ + fmt_dep, + pcm_basic_dep, + song_dep, + db_plugins_dep, + ], + ) + test( 'test_translate_song', executable(