Skip to content

Commit

Permalink
test-double test-main-code
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jan 30, 2025
1 parent b65407c commit b8b180e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test_double/doubles/limestone_double.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <dlfcn.h>

#include "glog/logging.h"
//#include "shirakami/logging.h" // span_printer for test-main

#include "limestone_double.h"

Expand Down Expand Up @@ -109,3 +110,36 @@ void _ZN9limestone3api9datastore33switch_available_boundary_versionENS0_18write_
#endif

#undef EXTERN_C

#if 0
// example
int main(int argc, char *argv[]) {
decltype(&main) orig_main = reinterpret_cast<decltype(&main)>(dlsym(RTLD_NEXT, "main"));
test_double::log_channel_add_entry1::hook_func = [](
test_double::log_channel_add_entry1::orig_type orig_func, limestone::api::log_channel* this_ptr,
limestone::api::storage_id_type storage_id, std::string_view key, std::string_view value,
limestone::api::write_version_type write_version) {
// spy func; log and pass to orig
LOG(INFO) << "add_entry 1 storage_id:" << storage_id << " key:" << key;
orig_func(this_ptr, storage_id, key, value, write_version);
return;
};
test_double::log_channel_add_entry2::hook_func = [](
test_double::log_channel_add_entry2::orig_type orig_func, limestone::api::log_channel* this_ptr,
limestone::api::storage_id_type storage_id, std::string_view key, std::string_view value,
limestone::api::write_version_type write_version, const std::vector<limestone::api::blob_id_type>& large_objects) {
// log and bypass to add_entry without blob
LOG(INFO) << "add_entry 2 storage_id:" << storage_id << " key:" << key << " blob:" << shirakami::span_printer(large_objects);
this_ptr->add_entry(storage_id, key, value, write_version);
return;
};
test_double::datastore_switch_available_boundary_version::hook_func = [](
test_double::datastore_switch_available_boundary_version::orig_type orig_func, limestone::api::datastore* this_ptr,
limestone::api::write_version_type version) {
// only logging, ignore
LOG(INFO) << "switch_available_boundary_version" /*<< version:" << version*/;
return;
};
return orig_main(argc, argv);
}
#endif

0 comments on commit b8b180e

Please sign in to comment.