diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 91f3fdc5abb..9b3e6dd2f68 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -68,7 +68,6 @@ set(CORE_TEST_SOURCES test_list.cpp test_mixed_null_assertions.cpp test_object_id.cpp - test_optional.cpp test_priority_queue.cpp test_replication.cpp test_safe_int_ops.cpp diff --git a/test/benchmark-common-tasks-ios/Base.lproj/LaunchScreen.xib b/test/benchmark-common-tasks-ios/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 5a9b673445f..00000000000 --- a/test/benchmark-common-tasks-ios/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/benchmark-common-tasks-ios/Base.lproj/Main.storyboard b/test/benchmark-common-tasks-ios/Base.lproj/Main.storyboard deleted file mode 100644 index f56d2f3bb56..00000000000 --- a/test/benchmark-common-tasks-ios/Base.lproj/Main.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/benchmark-common-tasks-ios/Images.xcassets/AppIcon.appiconset/Contents.json b/test/benchmark-common-tasks-ios/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 36d2c80d889..00000000000 --- a/test/benchmark-common-tasks-ios/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/test/benchmark-common-tasks-ios/Info.plist b/test/benchmark-common-tasks-ios/Info.plist deleted file mode 100644 index 40c6215d906..00000000000 --- a/test/benchmark-common-tasks-ios/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/test/benchmark-common-tasks-ios/ViewController.h b/test/benchmark-common-tasks-ios/ViewController.h deleted file mode 100644 index 768ff025b4b..00000000000 --- a/test/benchmark-common-tasks-ios/ViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/test/benchmark-common-tasks-ios/ViewController.mm b/test/benchmark-common-tasks-ios/ViewController.mm deleted file mode 100644 index 28a5ac1d026..00000000000 --- a/test/benchmark-common-tasks-ios/ViewController.mm +++ /dev/null @@ -1,29 +0,0 @@ -#import "ViewController.h" - -#include "test_path.hpp" - -extern "C" int benchmark_common_tasks_main(); - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - std::string tmp_dir{[NSTemporaryDirectory() UTF8String]}; - realm::test_util::set_test_path_prefix(tmp_dir); - - std::string resource_path{[[[NSBundle mainBundle] resourcePath] UTF8String]}; - realm::test_util::set_test_resource_path(resource_path + "/"); - - [[NSProcessInfo processInfo] performActivityWithOptions:NSActivityLatencyCritical reason:@"benchmark-common-tasks" usingBlock:^{ - benchmark_common_tasks_main(); - }]; - - exit(0); -} - -@end diff --git a/test/benchmark-common-tasks-ios/main.m b/test/benchmark-common-tasks-ios/main.m deleted file mode 100644 index b53eb7db03d..00000000000 --- a/test/benchmark-common-tasks-ios/main.m +++ /dev/null @@ -1,13 +0,0 @@ -#import - -@interface AppDelegate : UIResponder -@property (strong, nonatomic) UIWindow *window; -@end -@implementation AppDelegate -@end - -int main(int argc, char * argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/test/benchmark-history-types/.gitignore b/test/benchmark-history-types/.gitignore deleted file mode 100644 index 525503f3bd9..00000000000 --- a/test/benchmark-history-types/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/*.d -/*.o - -# Coverage data -/*.gcno -/*.gcda - -/bench -/bench-dbg -/bench-cov - -# Result files -/results.* diff --git a/test/benchmark-history-types/main.cpp b/test/benchmark-history-types/main.cpp deleted file mode 100644 index f842ed8321f..00000000000 --- a/test/benchmark-history-types/main.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include -#include - -#include -#include -#include - -#include "../util/timer.hpp" -#include "../util/random.hpp" -#include "../util/benchmark_results.hpp" - -using namespace realm; -using namespace realm::util; -using namespace realm::test_util; - - -namespace { - -std::unique_ptr make_history() -{ - return make_client_history(); - // return make_in_realm_history(); -} - - -// Make a Realm of considerable size. Then perform as series of write -// transactions via one SharedGroup. At the same time (by the same thread) -// occasionally advance a read transaction via another SharedGroup. This will -// produce a situation with a varying number of concurrently locked snapshots. -class PeakFileSizeTask { -public: - PeakFileSizeTask() - { - std::string path = "/tmp/benchmark-history-types.realm"; - util::File::try_remove(path); - - reader_history = make_history(); - reader_shared_group.reset(new DB(*reader_history, path)); - - writer_history = make_history(); - writer_shared_group.reset(new DB(*writer_history, path)); - - WriteTransaction wt(*writer_shared_group); - TableRef table = wt.add_table("table"); - for (size_t i = 0; i < num_cols; ++i) - table->add_column(type_Int, ""); - table->add_empty_row(num_rows); - for (size_t i = 0; i < num_rows; ++i) { - if (i % REALM_MAX_BPNODE_SIZE == 0) { // REALM_MAX_BPNODE_SIZE = 1000 - for (size_t j = 0; j < num_cols; ++j) - table->set_int(j, i, 65536L + long(i) + long(j)); - } - } - wt.commit(); - - reader_shared_group->begin_read(); - } - - void run() - { - for (size_t i = 0; i < num_transactions; ++i) { - if (i % max_num_locked_snapshots == 0) - LangBindHelper::advance_read(*reader_shared_group); - WriteTransaction wt(*writer_shared_group); - TableRef table = wt.get_table("table"); - for (size_t j = 0; j < num_modifications; ++j) { - size_t col_ndx = (j + i) % num_cols; - size_t row_ndx = (size_t((double(num_rows - 1) / num_modifications - 1) * j) + i) % num_rows; - table->set_int(col_ndx, row_ndx, 262144L + long(j) + long(i)); - } - wt.commit(); - } - } - -private: - const size_t num_cols = 8; - const size_t num_rows = 10000; - const size_t num_transactions = 10000; - const size_t num_modifications = 20; - const size_t max_num_locked_snapshots = 8; - - std::unique_ptr reader_history; - std::unique_ptr reader_shared_group; - - std::unique_ptr writer_history; - std::unique_ptr writer_shared_group; -}; - - -class Task { -public: - Task(int num_readers, bool grow) - : m_num_readers(num_readers) - , m_grow(grow) - { - std::string path = "/tmp/benchmark-history-types.realm"; - util::File::try_remove(path); - - reader_histories.reset(new std::unique_ptr[num_readers]); - reader_shared_groups.reset(new std::unique_ptr[num_readers]); - - for (int i = 0; i < num_readers; ++i) { - reader_histories[i] = make_history(); - reader_shared_groups[i].reset(new DB(*reader_histories[i], path)); - } - - writer_history = make_history(); - writer_shared_group.reset(new DB(*writer_history, path)); - - WriteTransaction wt(*writer_shared_group); - TableRef table = wt.add_table("table"); - table->add_column(type_Int, "i"); - if (!grow) - table->add_empty_row(); - wt.commit(); - } - - void run() - { - for (int i = 0; i < 64; ++i) { - int reader_ndx = i % m_num_readers; - if (m_num_readers > 0) { - reader_shared_groups[reader_ndx]->end_read(); - reader_shared_groups[reader_ndx]->begin_read(); - } - WriteTransaction wt(*writer_shared_group); - TableRef table = wt.get_table("table"); - if (m_grow) { - table->add_empty_row(); - table->set_int(0, i, i); - } - else { - table->set_int(0, 0, i); - } - wt.commit(); - } - } - -private: - const int m_num_readers; - const bool m_grow; - - std::unique_ptr[]> reader_histories; - std::unique_ptr[]> reader_shared_groups; - - std::unique_ptr writer_history; - std::unique_ptr writer_shared_group; -}; - -} // unnamed namespace - - -int main() -{ - int max_lead_text_size = 25; - BenchmarkResults results(max_lead_text_size); - - Timer timer(Timer::type_UserTime); - { - /* - for (int i = 0; i != 1; ++i) { - PeakFileSizeTask task; - timer.reset(); - task.run(); - results.submit("dummy", timer); - } - results.finish("dummy", "Dummy"); - */ - // No readers (no grow) - for (int i = 0; i != 25; ++i) { - Task task(0, false); - timer.reset(); - task.run(); - results.submit("0_readers_no_grow", timer); - } - results.finish("0_readers_no_grow", "No readers (no grow)"); - - // One reader (no grow) - for (int i = 0; i != 25; ++i) { - Task task(1, false); - timer.reset(); - task.run(); - results.submit("1_readers_no_grow", timer); - } - results.finish("1_readers_no_grow", "One reader (no grow)"); - - // Two readers (no grow) - for (int i = 0; i != 25; ++i) { - Task task(2, false); - timer.reset(); - task.run(); - results.submit("2_readers_no_grow", timer); - } - results.finish("2_readers_no_grow", "Two readers (no grow)"); - - // Five readers (no grow) - for (int i = 0; i != 25; ++i) { - Task task(5, false); - timer.reset(); - task.run(); - results.submit("5_readers_no_grow", timer); - } - results.finish("5_readers_no_grow", "Five readers (no grow)"); - - // Fifteen readers (no grow) - for (int i = 0; i != 25; ++i) { - Task task(15, false); - timer.reset(); - task.run(); - results.submit("15_readers_no_grow", timer); - } - results.finish("15_readers_no_grow", "Fifteen readers (no grow)"); - - // No readers (grow) - for (int i = 0; i != 25; ++i) { - Task task(0, true); - timer.reset(); - task.run(); - results.submit("0_readers_grow", timer); - } - results.finish("0_readers_grow", "No readers (grow)"); - - // One reader (grow) - for (int i = 0; i != 25; ++i) { - Task task(1, true); - timer.reset(); - task.run(); - results.submit("1_readers_grow", timer); - } - results.finish("1_readers_grow", "One reader (grow)"); - - // Two readers (grow) - for (int i = 0; i != 25; ++i) { - Task task(2, true); - timer.reset(); - task.run(); - results.submit("2_readers_grow", timer); - } - results.finish("2_readers_grow", "Two readers (grow)"); - - // Five readers (grow) - for (int i = 0; i != 25; ++i) { - Task task(5, true); - timer.reset(); - task.run(); - results.submit("5_readers_grow", timer); - } - results.finish("5_readers_grow", "Five readers (grow)"); - - // Fifteen readers (grow) - for (int i = 0; i != 25; ++i) { - Task task(15, true); - timer.reset(); - task.run(); - results.submit("15_readers_grow", timer); - } - results.finish("15_readers_grow", "Fifteen readers (grow)"); - } -} diff --git a/test/benchmark-index/mkindex.cpp b/test/benchmark-index/mkindex.cpp deleted file mode 100644 index 66c2c18b34b..00000000000 --- a/test/benchmark-index/mkindex.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include -#include - -using namespace realm; - -REALM_TABLE_7(IndexTable, s1, String, n1, Int, n2, Int, n3, Int, n4, Int, n5, Int, s2, String) - - -int main() -{ - Group* g = new Group(); - - BasicTableRef t = g->add_table("test"); - srandom(1); - printf("Adding rows\n"); - for (size_t i = 0; i < 10000000; ++i) { - long n1 = random() % 1000; - long n2 = random() % 1000; - long n3 = random() % 1000; - long n4 = random() % 1000; - long n5 = random() % 1000; - char s1[512]; - sprintf(s1, "%ldHello%ld", n1, n2); - char s2[512]; - sprintf(s2, "%ldWorld%ld", n3, n4); - t->add(s1, n1, n2, n3, n4, n5, s2); - if (i % 50000 == 0) { - printf("(%ld) ", i); - } - } - printf("\nOptimizing\n"); - t->optimize(); - printf("Creating index\n"); - t->column().s1.add_search_index(); - printf("Writing to disk\n"); - g->write("test.realm"); -} diff --git a/test/benchmark-insert-add/.gitignore b/test/benchmark-insert-add/.gitignore deleted file mode 100644 index c56c763dec3..00000000000 --- a/test/benchmark-insert-add/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/*.d -/*.o - -# Coverage data -/*.gcno -/*.gcda - -/add_insert -/add_insert-dbg -/add_insert-cov diff --git a/test/benchmark-insert-add/add_insert.cpp b/test/benchmark-insert-add/add_insert.cpp deleted file mode 100644 index fc9f5c6e2a6..00000000000 --- a/test/benchmark-insert-add/add_insert.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include - -#include - -#include - -#include "../util/timer.hpp" - -using namespace realm; -using namespace realm::util; - - -namespace { - -enum Mode { - mode_UseShared, - mode_UseGroup, - mode_UseTable, -}; - -REALM_TABLE_5(TestTable, x, Int, s1, String, b, Bool, s2, String, s3, String) - - -void usage() -{ - std::cout << "Usage: add_insert [-h] [-s mem|full|async] [-a]" << std::endl; - std::cout << " -h : this text" << std::endl; - std::cout << " -s : use shared group (default: no)" << std::endl; - std::cout << " -i : insert at front (defalut: no - append)" << std::endl; - std::cout << " -N : number of rows to add" << std::endl; - std::cout << " -n : rows between print outs" << std::endl; - std::cout << " -g : use group (default: no)" << std::endl; - std::cout << " -r : rows/commit (default: 1)" << std::endl; - std::cout << " -R : insert at random position (only useful with -i)" << std::endl; -} - -} // anonymous namespace - - -int main(int argc, char* argv[]) -{ - size_t N = 100000000; - size_t n = 50000; - size_t rows_per_commit = 1; - TestTable t; - - int c; - extern char* optarg; - - bool use_shared = false; - DBOptions::Durability dlevel = DBOptions::Durability::Full; - bool do_insert = false; - bool use_group = false; - bool random_insert = false; - - // FIXME: 'getopt' is POSIX/Linux specific. We should replace with - // code similar to what appears in main() in - // "realm_tools/src/realm/tools/prompt/prompt.cpp". - while ((c = getopt(argc, argv, "hs:iN:n:r:gR")) != EOF) { - switch (c) { - case 'h': - usage(); - return 0; - case 'R': - random_insert = true; - break; - case 's': - use_shared = true; - if (strcmp(optarg, "mem") == 0) { - dlevel = DBOptions::Durability::MemOnly; - } - else { - if (strcmp(optarg, "full") == 0) { - dlevel = DBOptions::Durability::Full; - } - else { - if (strcmp(optarg, "async") == 0) { - dlevel = DBOptions::Durability::Async; - } - else { - std::cout << "durability must be either mem or full" << std::endl; - return 1; - } - } - } - break; - case 'i': - do_insert = true; - break; - case 'N': - N = size_t(atol(optarg)); - break; - case 'n': - n = size_t(atol(optarg)); - break; - case 'g': - use_group = true; - break; - case 'r': - rows_per_commit = size_t(atol(optarg)); - break; - default: - std::cout << "Unknown option" << std::endl; - usage(); - return 1; - } - } - - if (use_group && use_shared) { - std::cout << "You cannot specify -g and -s at the same time." << std::endl; - usage(); - return 1; - } - - Mode m; - if (use_group) { - m = mode_UseGroup; - } - else { - if (use_shared) { - m = mode_UseShared; - } - else { - m = mode_UseTable; - } - } - - std::cout << "# Parameters: " << std::endl; - std::cout << "# number of rows : " << N << std::endl; - std::cout << "# rows per commit : " << rows_per_commit << std::endl; - std::cout << "# output frequency : " << n << std::endl; - std::cout << "# mode : " << m << std::endl; - if (do_insert) { - std::cout << "# do inserts" << std::endl; - std::cout << "# random insert : " << random_insert << std::endl; - } - - if (random_insert) { // initialize RNG - srandom(0); - } - - while (File::exists("test.realm.lock")) { - usleep(10000); - } - File::try_remove("test.realm"); - File::try_remove("gtest.realm"); - - DB sg = DB("test.realm", false, dlevel); - Group g("gtest.realm", nullptr, Group::mode_ReadWrite); - - switch (m) { - case mode_UseShared: { - WriteTransaction wt(sg); - BasicTableRef t = wt.add_table("test"); - wt.commit(); - break; - } - case mode_UseGroup: { - BasicTableRef t = g.add_table("test"); - try { - g.commit(); - } - catch (std::runtime_error& e) { - std::cerr << "Cannot create table: " << e.what() << std::endl; - return 1; - } - break; - } - case mode_UseTable: - break; - } - - test_util::Timer timer(test_util::Timer::type_RealTime); - for (size_t i = 0; i < N / rows_per_commit; ++i) { - switch (m) { - case mode_UseShared: { - WriteTransaction wt(sg); - BasicTableRef t1 = wt.get_table("test"); - { - for (size_t j = 0; j < rows_per_commit; ++j) { - if (do_insert) { - size_t k = 0; - if (random_insert && t1->size() > 0) { - k = size_t(random() % t1->size()); - } - t1->insert(k, N, "Hello", i % 2, "World", "Smurf"); - } - else { - t1->add(N, "Hello", i % 2, "World", "Smurf"); - } - } - } - wt.commit(); - break; - } - case mode_UseGroup: { - BasicTableRef t1 = g.get_table("test"); - for (size_t j = 0; j < rows_per_commit; ++j) { - if (do_insert) { - size_t k = 0; - if (random_insert && t1->size() > 0) { - k = size_t(random() % t1->size()); - } - t1->insert(k, N, "Hello", i % 2, "World", "Smurf"); - } - else { - t1->add(N, "Hello", i % 2, "World", "Smurf"); - } - } - try { - g.commit(); - } - catch (File::PermissionDenied& e) { - std::cerr << "commit (permission denied): " << e.what() << std::endl; - return 1; - } - catch (std::runtime_error& e) { - std::cerr << "commit (runtime error): " << e.what() << std::endl; - return 1; - } - break; - } - case mode_UseTable: - for (size_t j = 0; j < rows_per_commit; ++j) { - if (do_insert) { - size_t k = 0; - if (random_insert && t.size() > 0) { - k = size_t(random() % t.size()); - } - t.insert(k, N, "Hello", i % 2, "World", "Smurf"); - } - else { - t.add(N, "Hello", i % 2, "World", "Smurf"); - } - } - break; - } - - if (((i * rows_per_commit) % n) == 0 && i > 0) { - double dt = timer.get_elapsed_time(); - std::cout << i * rows_per_commit << ";" << dt << ";" << double(i * rows_per_commit) / dt << ";" - << dt / double(i * rows_per_commit) << std::endl; - } - } - return 0; -} diff --git a/test/benchmark-insert-add/batched.sh b/test/benchmark-insert-add/batched.sh deleted file mode 100755 index e17916c4dac..00000000000 --- a/test/benchmark-insert-add/batched.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -PATH=/bin:/usr/bin -N=1000000 -n=50000 -m=5 - -p=1 -for i in $(seq 1 $m); do - ./add_insert -s full -N $N -n $n > append_transact_full_${p}.dat - p=$((10*$p)) -done - -tmpfile=$(mktemp /tmp/$0.XXXXXX) -echo "set datafile separator \";\"" >> $tmpfile -echo "set terminal pdfcairo color enhanced" >> $tmpfile -echo "set output \"batched.pdf\"" >> $tmpfile -echo "set title \"Batched transactions to-disk\"" >> $tmpfile -echo "set xlabel \"Number of rows\"" >> $tmpfile -echo "set ylabel \"Rows/sec\"" >> $tmpfile -echo -n "plot " >> $tmpfile -p=1 -for i in $(seq 1 $m); do - echo -n "\"append_transact_full_${p}.dat\" u 1:3 t \"$p\" w l " >> $tmpfile - if [ "$i" -ne "$m" ]; then - echo -n "," >> $tmpfile - fi - p=$((10*$p)) -done -gnuplot $tmpfile -rm -f $tmpfile diff --git a/test/benchmark-insert-add/performance.gnuplot b/test/benchmark-insert-add/performance.gnuplot deleted file mode 100755 index fa643ffeb7d..00000000000 --- a/test/benchmark-insert-add/performance.gnuplot +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/gnuplot -set datafile separator ";" -set terminal pdfcairo color enhanced -set output "performance.pdf" - -# ./add_insert -N 50000000 -n 50000 | tee append_table_inmem.dat -set title "In-memory table append" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "append_table_inmem.dat" using 1:3 with lines - -# ./add_insert -i -N 50000000 -n 50000 | tee insert_table_inmem.dat -set title "In-memory table insert" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "insert_table_inmem.dat" using 1:3 with lines - -# ./add_insert -s mem -N 50000 -n 500 | tee append_transact_inmem.dat -set title "In-memory transaction append" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "append_transact_inmem.dat" using 1:3 with lines - -# ./add_insert -s mem -N 50000 -n 500 | tee insert_transact_inmem.dat -set title "In-memory transaction insert" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "insert_transact_inmem.dat" using 1:3 with lines - -# ./add_insert -g -N 50000 -n 500 | tee append_group_dat -set title "To-disk group append" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "append_group.dat" using 1:3 with lines - -# ./add_insert -g -i -N 50000 -n 500 | tee insert_group.dat -set title "To-disk group insert" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "insert_group.dat" using 1:3 with lines - -# ./add_insert -s full -N 50000 -n 500 | tee append_transact_full.dat -set title "To-disk sync transaction append" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "append_transact_full.dat" using 1:3 with lines - -# ./add_insert -s full -N 50000 -n 500 | tee insert_transact_full.dat -set title "To-disk sync transaction insert" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "insert_transact_full.dat" using 1:3 with lines - -# ./add_insert -s async -N 50000 -n 500 | tee append_transact_async.dat -set title "To-disk async transaction append" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "append_transact_async.dat" using 1:3 with lines - -# ./add_insert -s async -N 50000 -n 500 | tee insert_transact_async.dat -set title "To-disk async transaction insert" -set xlabel "Number of rows" -set ylabel "Rows/sec" -plot "insert_transact_async.dat" using 1:3 with lines diff --git a/test/benchmark-insert-add/run.sh b/test/benchmark-insert-add/run.sh deleted file mode 100755 index 5493979f890..00000000000 --- a/test/benchmark-insert-add/run.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -PATH=/bin:/usr/bin -N=5000 -n=10 - -./add_insert -N $(($N*100)) -n $(($n*100)) > append_table_inmem.dat -./add_insert -i -N $(($N*100)) -n $(($n*100)) > insert_table_inmem.dat -./add_insert -s mem -N $N -n $n > append_transact_inmem.dat -./add_insert -i -s mem -N $N -n $n > insert_transact_inmem.dat -./add_insert -g -N $N -n $n > append_group.dat -./add_insert -g -i -N $N -n $n > insert_group.dat -./add_insert -s full -N $N -n $n > append_transact_full.dat -./add_insert -i -s full -N $N -n $n > insert_transact_full.dat -./add_insert -s async -N $(($N*10)) -n $(($n*10)) > append_transact_async.dat -./add_insert -i -s async -N $(($N*10)) -n $(($n*10)) > insert_transact_async.dat -./performance.gnuplot diff --git a/test/benchmark-prealloc/.gitignore b/test/benchmark-prealloc/.gitignore deleted file mode 100644 index f36b23963ef..00000000000 --- a/test/benchmark-prealloc/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/*.d -/*.o - -# Coverage data -/*.gcno -/*.gcda - -/benchmark-prealloc -/benchmark-prealloc-dbg -/benchmark-prealloc-cov diff --git a/test/benchmark-prealloc/main.cpp b/test/benchmark-prealloc/main.cpp deleted file mode 100644 index b77ecf5c06f..00000000000 --- a/test/benchmark-prealloc/main.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include - -#include -#include - -using namespace realm; -using namespace realm::util; - - -namespace { - -REALM_TABLE_2(Alpha, foo, Int, bar, Int) - -} // anonymous namespace - - -#define DIR "/tmp" - -int main() -{ - bool no_create = false; - DBOptions::Durability dlevel = DBOptions::Durability::Full; - - File::try_remove(DIR "/benchmark-prealloc.realm"); - DB sg(DIR "/benchmark-prealloc.realm", no_create, {dlevel}); - - File::try_remove(DIR "/benchmark-prealloc-interfere1.realm"); - DB sg_interfere1(DIR "/benchmark-prealloc-interfere1.realm", no_create, dlevel); - - File::try_remove(DIR "/benchmark-prealloc-interfere2.realm"); - DB sg_interfere2(DIR "/benchmark-prealloc-interfere2.realm", no_create, dlevel); - - File::try_remove(DIR "/benchmark-prealloc-interfere3.realm"); - DB sg_interfere3(DIR "/benchmark-prealloc-interfere3.realm", no_create, dlevel); - - int n_outer = 100; - { - time_t begin = time(0); - - int n_inner = 100; - for (int i = 0; i < n_outer; ++i) { - std::cerr << "."; - for (int j = 0; j < n_inner; ++j) { - { - WriteTransaction wt(sg); - Alpha::Ref t = wt.get_or_add_table("alpha"); - for (int j = 0; j < 1000; ++j) - t->add(65536, 65536); - wt.commit(); - } - // Interference - for (int k = 0; k < 2; ++k) { - { - WriteTransaction wt(sg_interfere1); - Alpha::Ref t = wt.get_or_add_table("alpha"); - for (int j = 0; j < 100; ++j) - t->add(65536, 65536); - wt.commit(); - } - { - WriteTransaction wt(sg_interfere2); - Alpha::Ref t = wt.get_or_add_table("alpha"); - for (int j = 0; j < 400; ++j) - t->add(65536, 65536); - wt.commit(); - } - { - WriteTransaction wt(sg_interfere3); - Alpha::Ref t = wt.get_or_add_table("alpha"); - for (int j = 0; j < 1600; ++j) - t->add(65536, 65536); - wt.commit(); - } - } - } - } - std::cerr << "\n"; - - time_t end = time(0); - std::cerr << "Small write transactions per second = " << ((n_outer * n_inner * 7 / double(end - begin))) - << std::endl; - } - - { - time_t begin = time(0); - - int n_inner = 10; - for (int i = 0; i < n_outer; ++i) { - std::cerr << "x"; - for (int j = 0; j < n_inner; ++j) { - { - WriteTransaction wt(sg); - Alpha::Ref t = wt.get_table("alpha"); - t->column().foo += 1; - t->column().bar += 1; - wt.commit(); - } - } - } - std::cerr << "\n"; - - time_t end = time(0); - std::cerr << "Large write transactions per second = " << ((n_outer * n_inner / double(end - begin))) - << std::endl; - } -} diff --git a/test/benchmark-row-accessor/.gitignore b/test/benchmark-row-accessor/.gitignore deleted file mode 100644 index 525503f3bd9..00000000000 --- a/test/benchmark-row-accessor/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/*.d -/*.o - -# Coverage data -/*.gcno -/*.gcda - -/bench -/bench-dbg -/bench-cov - -# Result files -/results.* diff --git a/test/benchmark-row-accessor/main.cpp b/test/benchmark-row-accessor/main.cpp deleted file mode 100644 index f4bbc669ad7..00000000000 --- a/test/benchmark-row-accessor/main.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "../util/timer.hpp" -#include "../util/random.hpp" -#include "../util/benchmark_results.hpp" - -using namespace realm; -using namespace realm::util; -using namespace realm::test_util; - - -/// Row Accessor Benchmarks -/// -/// To measure the performance of the row accessor only, the table tested on is -/// minimal, one empty row nothing else. Bigger tables might be necessary, but -/// beware of skewed results. - -namespace { - -enum DetachOrder { AttachOrder, RevAttOrder, RandomOrder }; - -/// Benchmark the (=) operator on row accessors. -/// -/// The (=) operator causes a reattachment a row expression to the table. -/// `heap` signfies that this reattachment will happen many times over. -/// -/// Here it is in pseduocode: -/// -/// table = add_empty_row(table()) -/// rows = replicate(table[0], n) -/// time { -/// repeat 10000 * 10000 times { -/// rows[random(n)] = table[0] -/// } -/// } -/// -void heap(Timer& timer, BenchmarkResults& results, int n, const char* ident, const char* lead_text) -{ - Table table; - table.add_empty_row(); - std::unique_ptr rows(new Row[n]); - for (int i = 0; i < n; ++i) - rows[i] = table[0]; - - // Generate random numbers before timing because Random is slooow - // (thread-safe): - int m = 10000; - std::unique_ptr indexes(new int[m]); - Random random; - for (int i = 0; i < m; ++i) - indexes[i] = random.draw_int_mod(n); - // indexes is not guaranteed to contain all indexes from 0 to n.. - - // Now get to business: - timer.reset(); - for (int j = 0; j < 10000; ++j) { - for (int i = 0; i < m; ++i) - rows[indexes[i]] = table[0]; - } - results.submit_single(ident, lead_text, timer); -} - -/// Benchmark the (=) operator on row accessors, while detaching them in / -/// various orders. `balloon` signifies that the row accessors are first -/// attached (inflating a balloon) and then detached in some order -/// (deflating the balloon). -/// -/// Here it is in pseduocode: -/// -/// table = add_empty_row(table()) -/// detach_indexes = sort(detach_order, range(balloon_size)) -/// time { -/// rows = replicate(table[0], ballon_size) -/// for i in range(ballon_size) { -/// rows[detach_indexes[i]].detach() -/// } -/// } -/// -void balloon(Timer& timer, BenchmarkResults& results, int balloon_size, DetachOrder detach_order, const char* ident, - const char* lead_text) -{ - Table table; - table.add_empty_row(); - std::unique_ptr rows(new Row[balloon_size]); - std::unique_ptr detach_indexes(new int[balloon_size]); - for (int i = 0; i < balloon_size; ++i) - detach_indexes[i] = i; - Random random; - switch (detach_order) { - case AttachOrder: - break; - case RevAttOrder: - std::reverse(detach_indexes.get(), detach_indexes.get() + balloon_size); - break; - case RandomOrder: - random.shuffle(detach_indexes.get(), detach_indexes.get() + balloon_size); - break; - } - int n = (100000000L + balloon_size - 1) / balloon_size; - timer.reset(); - for (int j = 0; j < n; ++j) { - for (int i = 0; i < balloon_size; ++i) - rows[i] = table[0]; - for (int i = 0; i < balloon_size; ++i) - rows[detach_indexes[i]].detach(); - } - results.submit_single(ident, lead_text, timer); -} - -} // namespace - - -int main() -{ - int max_lead_text_size = 22; - BenchmarkResults results(max_lead_text_size); - - Timer timer_total(Timer::type_UserTime); - Timer timer(Timer::type_UserTime); - - heap(timer, results, 1, "heap_1", "Heap 1"); - heap(timer, results, 10, "heap_10", "Heap 10"); - heap(timer, results, 100, "heap_100", "Heap 100"); - heap(timer, results, 1000, "heap_1000", "Heap 1000"); - - balloon(timer, results, 10, AttachOrder, "balloon_10", "Balloon 10"); - balloon(timer, results, 10, RevAttOrder, "balloon_10_reverse", "Balloon 10 (reverse)"); - balloon(timer, results, 10, RandomOrder, "balloon_10_random", "Balloon 10 (random)"); - - balloon(timer, results, 100, AttachOrder, "balloon_100", "Balloon 100"); - balloon(timer, results, 100, RevAttOrder, "balloon_100_reverse", "Balloon 100 (reverse)"); - balloon(timer, results, 100, RandomOrder, "balloon_100_random", "Balloon 100 (random)"); - - balloon(timer, results, 1000, AttachOrder, "balloon_1000", "Balloon 1000"); - balloon(timer, results, 1000, RevAttOrder, "balloon_1000_reverse", "Balloon 1000 (reverse)"); - balloon(timer, results, 1000, RandomOrder, "balloon_1000_random", "Balloon 1000 (random)"); - - results.submit_single("total_time", "Total time", timer_total); -} diff --git a/test/benchmark-transaction/run-benchmarks.sh b/test/benchmark-transaction/run-benchmarks.sh deleted file mode 100755 index 83b51057067..00000000000 --- a/test/benchmark-transaction/run-benchmarks.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# run transaction benchmarks -# -# (C) Copyright 2012 by Realm, Inc. -# -PATH=/bin:/usr/bin - -Nrec=100000 # number of records -duration=120 # run time in secords -Nmax=10 # max number of threads - -function bench { - db=$1 - - out=${db}-tps.dat - rm -f $out - echo "# Database: ${db}" >> $out - echo "# Duration: ${duration}" >> $out - echo "# Readers Writers TPS(Reader) TPS(Writer) TPS(total)" >> $out - for i in $(seq 0 $Nmax) - do - for j in $(seq 0 $Nmax) - do - echo -n "$j $i " >> $out - rm -f test_${db}* - ./transact -w $i -r $j -f test_${db} -d ${db} -s -n $Nrec -t $duration >> $out - rm -f test_${db}* - done - done -} - -bench "realm" -bench "sqlite" -bench "mysql" -bench "sqlite-wal" diff --git a/test/benchmark-transaction/transact.cpp b/test/benchmark-transaction/transact.cpp deleted file mode 100644 index c910fb95f4b..00000000000 --- a/test/benchmark-transaction/transact.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace realm; - - -// which databases are possible -#define DB_REALM 0 -#define DB_SQLITE 1 -#define DB_MYSQL 2 -#define DB_SQLITE_WAL 3 - -// database parameters - primarily for MySQL -#define DB_HOST "localhost" -#define DB_USER "root" -#define DB_PASS "root" -#define DB_NAME "benchmark" - - -REALM_TABLE_2(TestTable, x, Int, y, Int) - - -struct thread_info { - pthread_t thread_id; - int thread_num; - char* datfile; -}; - - -static bool verbose; - -// Shared variables and mutex to protect them -static bool runnable = true; -static pthread_mutex_t mtx_runnable = PTHREAD_MUTEX_INITIALIZER; - -static double dt_readers; -static long iteration_readers; -static pthread_mutex_t mtx_readers = PTHREAD_MUTEX_INITIALIZER; -static double dt_writers; -static long iteration_writers; -static pthread_mutex_t mtx_writers = PTHREAD_MUTEX_INITIALIZER; - -double wall_time; - -void usage(const char* msg) -{ - if (strlen(msg) > 0) - std::cout << "Error: " << msg << std::endl << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << " -h : this text" << std::endl; - std::cout << " -w : number of writers" << std::endl; - std::cout << " -r : number of readers" << std::endl; - std::cout << " -f : database file" << std::endl; - std::cout << " -d : database (realm, sqlite, sqlite-wal or mysql)" << std::endl; - std::cout << " -t : duration (in secs)" << std::endl; - std::cout << " -n : number of rows" << std::endl; - std::cout << " -v : verbose" << std::endl; - std::cout << " -s : single run" << std::endl; - exit(-1); -} - - -// minimal version: no error checks! -void copy(const char* src, const char* dst) -{ - int fd_to, fd_from; - char buf[4096]; - ssize_t nread; - - fd_from = open(src, O_RDONLY); - fd_to = open(dst, O_WRONLY | O_CREAT | O_EXCL, 0666); - while ((nread = read(fd_from, buf, sizeof(buf))) > 0) { - char* out_ptr = buf; - ssize_t nwritten; - do { - nwritten = write(fd_to, out_ptr, nread); - if (nwritten >= 0) { - nread -= nwritten; - out_ptr += nwritten; - } - } while (nread > 0); - } - - close(fd_from); - close(fd_to); -} - -// copy table in mysql -void copy_db(const char* src, const char* dst) -{ - MYSQL* db; - char sql[128]; - - db = mysql_init(NULL); - mysql_real_connect(db, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0); - sprintf(sql, "DROP TABLE IF EXISTS %s", dst); - mysql_query(db, sql); - sprintf(sql, "CREATE TABLE %s LIKE %s", dst, src); - mysql_query(db, sql); - sprintf(sql, "INSERT INTO %s SELECT * FROM %s", dst, src); - mysql_query(db, sql); - mysql_close(db); -} - -double delta_time(struct timespec ts_1, struct timespec ts_2) -{ - return (double)ts_2.tv_sec + 1e-9 * (double)ts_2.tv_nsec - ((double)ts_1.tv_sec + 1e-9 * (double)ts_1.tv_nsec); -} - -void update_reader(struct timespec ts_1, struct timespec ts_2) -{ - double dt = delta_time(ts_1, ts_2); - pthread_mutex_lock(&mtx_readers); - dt_readers += dt; - iteration_readers++; - pthread_mutex_unlock(&mtx_readers); -} - - -void update_writer(struct timespec ts_1, struct timespec ts_2) -{ - double dt = delta_time(ts_1, ts_2); - pthread_mutex_lock(&mtx_writers); - dt_writers += dt; - iteration_writers++; - pthread_mutex_unlock(&mtx_writers); -} - - -// keep retrying -int db_retry(void* data, int i) -{ - return 1; -} - -static void* sqlite_reader(void* arg) -{ - struct timespec ts_1, ts_2; - sqlite3* db; - long int randy; - char* errmsg; - char sql[128]; - sqlite3_stmt* s; - char* tail; - long int c = 0; - - struct thread_info* tinfo = (struct thread_info*)arg; - srandom(tinfo->thread_num); - sqlite3_open(tinfo->datfile, &db); - sqlite3_busy_handler(db, &db_retry, NULL); - - sprintf(sql, "SELECT COUNT(*) FROM test WHERE y = @Y"); - sqlite3_prepare_v2(db, sql, 128, &s, (const char**)&tail); - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &errmsg); - randy = random() % 1000; - sqlite3_bind_int(s, 1, randy); - sqlite3_step(s); - c += sqlite3_column_int(s, 0); - - if (sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &errmsg) == SQLITE_BUSY) { - std::cout << "Oops" << std::endl; - } - sqlite3_clear_bindings(s); - sqlite3_reset(s); - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_reader(ts_1, ts_2); - } - sqlite3_close(db); - if (verbose) { - std::cout << "Reader threads " << tinfo->thread_num << ":" << c << std::endl; - } - return NULL; -} - -static void* mysql_reader(void* arg) -{ - struct timespec ts_1, ts_2; - long int randy; - char sql[128]; - MYSQL* db; - long int c = 0; - - struct thread_info* tinfo = (struct thread_info*)arg; - srandom(tinfo->thread_num); - - // open mysql - db = mysql_init(NULL); - if (mysql_real_connect(db, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0) == NULL) { - std::cout << "Cannot connect to MySQL" << std::endl; - } - mysql_autocommit(db, 0); - - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - if (mysql_query(db, "START TRANSACTION;")) { - std::cout << "MySQL error: " << mysql_errno(db) << std::endl; - } - randy = random() % 1000; - sprintf(sql, "SELECT COUNT(*) FROM %s WHERE y = %ld", tinfo->datfile, randy); - if (mysql_query(db, sql)) { - std::cout << "MySQL error in " << sql << ": " << mysql_errno(db) << std::endl; - } - MYSQL_RES* res = mysql_use_result(db); - MYSQL_ROW row = mysql_fetch_row(res); - c += atoi(row[0]); - mysql_free_result(res); - if (mysql_query(db, "COMMIT;")) { - std::cout << "Cannot commit" << std::endl; - } - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_reader(ts_1, ts_2); - } - if (verbose) { - std::cout << "Reader threads " << tinfo->thread_num << ":" << c << std::endl; - } - mysql_close(db); -} - -static void* realm_reader(void* arg) -{ - struct timespec ts_1, ts_2; - struct thread_info* tinfo = (struct thread_info*)arg; - size_t c = 0; - srandom(tinfo->thread_num); - clock_gettime(CLOCK_REALTIME, &ts_1); - DB sg(tinfo->datfile); - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - { - ReadTransaction rt(sg); - TestTable::ConstRef t = rt.get_table("test"); - long randy = random() % 1000; - c += t->where().y.equal(randy).count(); - } - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_reader(ts_1, ts_2); - } - if (verbose) { - std::cout << "Reader threads " << tinfo->thread_num << ":" << c << std::endl; - } - return NULL; -} - -static void* sqlite_writer(void* arg) -{ - sqlite3* db; - long int randx, randy; - char* errmsg; - char sql[128]; - struct timespec ts_1, ts_2; - sqlite3_stmt* s; - char* tail; - - struct thread_info* tinfo = (struct thread_info*)arg; - srandom(tinfo->thread_num); - - sqlite3_open(tinfo->datfile, &db); - sqlite3_busy_handler(db, &db_retry, NULL); - sprintf(sql, "UPDATE test SET x=@X WHERE y = @Y"); - sqlite3_prepare_v2(db, sql, 128, &s, (const char**)&tail); - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - sqlite3_exec(db, "BEGIN EXCLUSIVE TRANSACTION", NULL, NULL, &errmsg); - randx = random() % 1000; - randy = random() % 1000; - sqlite3_bind_int(s, 1, randx); - sqlite3_bind_int(s, 2, randy); - sqlite3_step(s); - sqlite3_free(errmsg); - if (sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &errmsg) == SQLITE_BUSY) { - std::cout << "Ooops" << std::endl; - } - sqlite3_clear_bindings(s); - sqlite3_reset(s); - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_writer(ts_1, ts_2); - } - sqlite3_close(db); - return NULL; -} - -static void* mysql_writer(void* arg) -{ - struct timespec ts_1, ts_2; - long int randx, randy; - char sql[128]; - MYSQL* db; - - struct thread_info* tinfo = (struct thread_info*)arg; - srandom(tinfo->thread_num); - - // open mysql - db = mysql_init(NULL); - mysql_real_connect(db, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0); - - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - if (mysql_query(db, "START TRANSACTION;")) { - std::cout << "MySQL error: " << mysql_errno(db) << std::endl; - } - randx = random() % 1000; - randy = random() % 1000; - sprintf(sql, "UPDATE %s SET x=%ld WHERE y = %ld", tinfo->datfile, randx, randy); - if (mysql_query(db, sql)) { - std::cout << "MySQL error in " << sql << ": " << mysql_errno(db) << std::endl; - } - if (mysql_query(db, "COMMIT;")) { - std::cout << "Cannot commit" << std::endl; - } - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_writer(ts_1, ts_2); - } - mysql_close(db); - return NULL; -} - -static void* realm_writer(void* arg) -{ - struct timespec ts_1, ts_2; - struct thread_info* tinfo = (struct thread_info*)arg; - srandom(tinfo->thread_num); - DB sg(tinfo->datfile); - while (true) { - pthread_mutex_lock(&mtx_runnable); - bool local_runnable = runnable; - pthread_mutex_unlock(&mtx_runnable); - if (!local_runnable) { - break; - } - clock_gettime(CLOCK_REALTIME, &ts_1); - - // execute transaction - { - WriteTransaction wt(sg); - BasicTableRef t = wt.get_or_add_table("test"); - long randx = random() % 1000; - long randy = random() % 1000; - TestTable::View tv = t->where().y.equal(randy).find_all(); - for (size_t j = 0; j < tv.size(); ++j) { - tv[j].x = randx; - } - wt.commit(); - } - - // update statistics - clock_gettime(CLOCK_REALTIME, &ts_2); - update_writer(ts_1, ts_2); - } - return NULL; -} - -void sqlite_create(const char* f, long n, bool wal) -{ - int i; - long randx, randy; - char sql[128]; - sqlite3* db; - char* errmsg; - - util::File::try_remove(f); - srandom(1); - - if (sqlite3_config(SQLITE_CONFIG_MULTITHREAD, 1) == SQLITE_ERROR) { - std::cout << "SQLite has no multi-threading support" << std::endl; - } - sqlite3_open(f, &db); - if (wal) { - sqlite3_exec(db, "CREATE TABLE test (x INT, y INT)", NULL, NULL, &errmsg); - sqlite3_exec(db, "PRAGMA journal_mode=wal", NULL, NULL, &errmsg); - } - else { - sqlite3_exec(db, "CREATE TABLE test (x INT, y INT)", NULL, NULL, &errmsg); - } - sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &errmsg); - for (i = 0; i < n; ++i) { - randx = random() % 1000; - randy = random() % 1000; - sprintf(sql, "INSERT INTO test VALUES (%ld, %ld)", randx, randy); - sqlite3_exec(db, sql, NULL, NULL, &errmsg); - } - sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &errmsg); - sqlite3_close(db); -} - -void mysql_create(const char* f, long n) -{ - int i; - long randx, randy; - char sql[128]; - MYSQL* db; - - db = mysql_init(NULL); - mysql_real_connect(db, DB_HOST, DB_USER, DB_PASS, DB_NAME, 0, NULL, 0); - mysql_query(db, "SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE"); - sprintf(sql, "DROP TABLE IF EXISTS %s", f); - mysql_query(db, sql); - sprintf(sql, "CREATE TABLE %s (x INT, y INT) ENGINE=innodb", f); - mysql_query(db, sql); - if (mysql_query(db, "START TRANSACTION;")) { - std::cout << "MySQL error: " << mysql_errno(db) << std::endl; - } - for (i = 0; i < n; ++i) { - randx = random() % 1000; - randy = random() % 1000; - sprintf(sql, "INSERT INTO %s VALUES (%ld, %ld)", f, randx, randy); - mysql_query(db, sql); - } - if (mysql_query(db, "COMMIT;")) { - std::cout << "Cannot commit" << std::endl; - } - mysql_close(db); -} - -void realm_create(const char* f, long n) -{ - util::File::try_remove(f); - util::File::try_remove(std::string(f) + ".lock"); - DB sg(f); - { - WriteTransaction wt(sg); - BasicTableRef t = wt.get_or_add_table("test"); - - srandom(1); - for (int i = 0; i < n; ++i) { - long randx = random() % 1000; - long randy = random() % 1000; - t->add(randx, randy); - } - wt.commit(); - } -} - - -void benchmark(bool single, int database, const char* datfile, long n_readers, long n_writers, unsigned int duration) -{ - pthread_attr_t attr; - struct thread_info* tinfo; - void* res; - - wall_time = 0.0; - dt_readers = 0.0; - iteration_readers = 0; - dt_writers = 0.0; - iteration_writers = 0; - runnable = true; - - if (!single) { - if (verbose) - std::cout << "Copying file" << std::endl; - if (database == DB_MYSQL) { - copy_db(datfile, ("tmp" + std::string(datfile)).c_str()); - } - else { - copy(datfile, ("tmp" + std::string(datfile)).c_str()); - } - } - if (database != DB_MYSQL) { - unlink(("tmp" + std::string(datfile)).c_str()); - unlink(("tmp" + std::string(datfile) + ".lock").c_str()); - } - - assert(pthread_attr_init(&attr) == 0); - assert((tinfo = (struct thread_info*)calloc(sizeof(struct thread_info), n_readers + n_writers)) != NULL); - - for (int i = 0; i < (n_readers + n_writers); ++i) { - tinfo[i].thread_num = i + 1; - if (single) { - tinfo[i].datfile = strdup(datfile); - } - else { - tinfo[i].datfile = strdup(("tmp" + std::string(datfile)).c_str()); - } - } - - if (verbose) - std::cout << "Starting threads" << std::endl; - struct timespec ts_1; - clock_gettime(CLOCK_REALTIME, &ts_1); - for (int i = 0; i < n_readers; ++i) { - switch (database) { - case DB_REALM: - pthread_create(&tinfo[i].thread_id, &attr, &realm_reader, &tinfo[i]); - break; - case DB_SQLITE: - case DB_SQLITE_WAL: - pthread_create(&tinfo[i].thread_id, &attr, &sqlite_reader, &tinfo[i]); - break; - case DB_MYSQL: - pthread_create(&tinfo[i].thread_id, &attr, &mysql_reader, &tinfo[i]); - break; - } - } - for (int i = 0; i < n_writers; ++i) { - int j = i + n_readers; - switch (database) { - case DB_REALM: - pthread_create(&tinfo[j].thread_id, &attr, &realm_writer, &tinfo[j]); - break; - case DB_SQLITE: - case DB_SQLITE_WAL: - pthread_create(&tinfo[j].thread_id, &attr, &sqlite_writer, &tinfo[j]); - break; - case DB_MYSQL: - pthread_create(&tinfo[j].thread_id, &attr, &mysql_writer, &tinfo[j]); - break; - } - } - - if (verbose) - std::cout << "Waiting for " << duration << " seconds" << std::endl; - sleep(duration); - - if (verbose) - std::cout << "Cancelling threads" << std::endl; - pthread_mutex_lock(&mtx_runnable); - runnable = false; - pthread_mutex_unlock(&mtx_runnable); - - if (verbose) - std::cout << "Waiting for threads" << std::endl; - for (int i = 0; i < n_readers; ++i) { - pthread_join(tinfo[i].thread_id, &res); - } - - for (int i = 0; i < n_writers; ++i) { - int j = i + n_readers; - pthread_join(tinfo[j].thread_id, &res); - } - struct timespec ts_2; - clock_gettime(CLOCK_REALTIME, &ts_2); - wall_time = delta_time(ts_1, ts_2); - - if (database == DB_REALM || database == DB_SQLITE) { - unlink(("tmp" + std::string(datfile)).c_str()); - unlink(("tmp" + std::string(datfile) + ".lock").c_str()); - } - free((void*)tinfo); -} - -int main(int argc, char* argv[]) -{ - int c; - long n_readers = -1, n_writers = -1, n_records = -1; - unsigned int duration = 0; - int database = -1; - bool single = true; - extern char* optarg; - char* datfile = NULL; - - verbose = false; - while ((c = getopt(argc, argv, "hr:w:f:n:t:d:vs")) != EOF) { - switch (c) { - case 'h': - usage(""); - case 'r': - n_readers = atoi(optarg); - break; - case 'w': - n_writers = atoi(optarg); - break; - case 'f': - datfile = strdup(optarg); - break; - case 'n': - n_records = atoi(optarg); - break; - case 't': - duration = atoi(optarg); - break; - case 'd': - if (strcmp(optarg, "realm") == 0) { - database = DB_REALM; - } - if (strcmp(optarg, "sqlite") == 0) { - database = DB_SQLITE; - } - if (strcmp(optarg, "sqlite-wal") == 0) { - database = DB_SQLITE_WAL; - } - if (strcmp(optarg, "mysql") == 0) { - database = DB_MYSQL; - } - break; - case 'v': - verbose = true; - break; - case 's': - single = true; - break; - default: - usage("Wrong option"); - } - } - - if (n_writers == -1) - n_writers = 2; - if (n_readers == -1) - n_readers = 2; - if (n_records == -1) - n_records = 10000; - if (duration < 1) - duration = 10; - if (database == -1 && single) - usage("-d missing"); - if (datfile == NULL) - datfile = strdup("test_db"); - - if (database == DB_SQLITE) { - sqlite3_config(SQLITE_CONFIG_SERIALIZED); - } - - if (verbose) - std::cout << "Creating test data for " << database << std::endl; - switch (database) { - case DB_REALM: - realm_create(datfile, n_records); - break; - case DB_SQLITE: - case DB_SQLITE_WAL: - sqlite_create(datfile, n_records, database == DB_SQLITE_WAL); - break; - case DB_MYSQL: - mysql_create(datfile, n_records); - break; - } - - // SQLite WAL is used - if (database == DB_SQLITE_WAL) { - database = DB_SQLITE; - } - - if (single) { - benchmark(true, database, datfile, n_readers, n_writers, duration); - std::cout << wall_time << " " << iteration_readers << " " << dt_readers << " " << iteration_writers << " " - << dt_writers << std::endl; - } - else { - std::cout << "# Columns: " << std::endl; - std::cout << "# 1. number of readers" << std::endl; - std::cout << "# 2. number of writers" << std::endl; - std::cout << "# 3. wall time" << std::endl; - std::cout << "# 4. read transactions" << std::endl; - std::cout << "# 5. read time" << std::endl; - std::cout << "# 6. writer transactions" << std::endl; - std::cout << "# 7. writer time" << std::endl; - for (int i = 0; i <= n_readers; ++i) { - for (int j = 0; j <= n_writers; ++j) { - benchmark(false, database, "test_db", i, j, duration); - std::cout << i << " " << j << " "; - std::cout << wall_time << " " << iteration_readers << " " << dt_readers << " " << iteration_writers - << " " << dt_writers << std::endl; - } - } - } -} diff --git a/test/object-store/CMakeLists.txt b/test/object-store/CMakeLists.txt index b3351be666e..cea16cd3346 100644 --- a/test/object-store/CMakeLists.txt +++ b/test/object-store/CMakeLists.txt @@ -238,8 +238,6 @@ if(NOT APPLE AND NOT EMSCRIPTEN AND NOT WINDOWS_STORE AND NOT ANDROID) endif() endif() -add_subdirectory(notifications-fuzzer) - if(NOT EMSCRIPTEN AND NOT WINDOWS_STORE AND NOT ANDROID) add_subdirectory(benchmarks) endif() diff --git a/test/object-store/notifications-fuzzer/CMakeLists.txt b/test/object-store/notifications-fuzzer/CMakeLists.txt deleted file mode 100644 index 5dec9df0e22..00000000000 --- a/test/object-store/notifications-fuzzer/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -macro(build_fuzzer_variant variant) - add_executable(${variant} command_file.hpp command_file.cpp ${variant}.cpp) - target_link_libraries(${variant} ObjectStore) - set_target_properties(${variant} PROPERTIES - EXCLUDE_FROM_ALL 1 - EXCLUDE_FROM_DEFAULT_BUILD 1) -endmacro() - -build_fuzzer_variant(fuzzer) -build_fuzzer_variant(fuzz-sorted-query) -build_fuzzer_variant(fuzz-unsorted-query) -build_fuzzer_variant(fuzz-sorted-linkview) -build_fuzzer_variant(fuzz-unsorted-linkview) diff --git a/test/object-store/notifications-fuzzer/command_file.cpp b/test/object-store/notifications-fuzzer/command_file.cpp deleted file mode 100644 index cf5ed816032..00000000000 --- a/test/object-store/notifications-fuzzer/command_file.cpp +++ /dev/null @@ -1,252 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#include "command_file.hpp" - -#include -#include - -#include -#include - -#include - -using namespace fuzzer; -using namespace realm; - -#if 0 -#define log(...) fprintf(stderr, __VA_ARGS__) -#else -#define log(...) -#endif - -template -static T read_value(std::istream& input) -{ - T ret; - input >> ret; - return ret; -} - -template -static auto make_reader(void (*fn)(RealmState&, Args...)) -{ - return [=](std::istream& input) { - return std::bind(fn, std::placeholders::_1, read_value(input)...); - }; -} - -static void run_add(RealmState& state, int64_t value) -{ - log("add %lld\n", value); - size_t ndx = state.table.add_empty_row(); - state.table.set_int(0, ndx, state.uid++); - state.table.set_int(1, ndx, value); -} - -static void run_modify(RealmState& state, size_t index, int64_t value) -{ - if (index < state.table.size()) { - log("modify %zu %lld\n", index, value); - state.table.set_int(1, index, value); - state.modified.push_back(state.table.get_int(0, index)); - } -} - -static void run_delete(RealmState& state, size_t index) -{ - if (index < state.table.size()) { - log("delete %zu (%lld)\n", index, state.table.get_int(1, index)); - state.table.move_last_over(index); - } -} - -static void run_commit(RealmState& state) -{ - log("commit\n"); - state.realm.commit_transaction(); - state.coordinator.on_change(); - state.realm.begin_transaction(); -} - -static void run_lv_insert(RealmState& state, size_t pos, size_t target) -{ - if (!state.lv) - return; - if (target < state.table.size() && pos <= state.lv->size()) { - log("lv insert %zu %zu\n", pos, target); - state.lv->insert(pos, target); - } -} - -static void run_lv_set(RealmState& state, size_t pos, size_t target) -{ - if (!state.lv) - return; - if (target < state.table.size() && pos < state.lv->size()) { - log("lv set %zu %zu\n", pos, target); - // We can't reliably detect self-assignment for verification, so don't do it - if (state.lv->get(pos).get_index() != target) - state.lv->set(pos, target); - } -} - -static void run_lv_move(RealmState& state, size_t from, size_t to) -{ - if (!state.lv) - return; - if (from < state.lv->size() && to < state.lv->size()) { - log("lv move %zu %zu\n", from, to); - // FIXME: only do the move if it has an effect to avoid getting a - // notification which we weren't expecting. This is really urgh. - for (size_t i = std::min(from, to); i < std::max(from, to); ++i) { - if (state.lv->get(i).get_index() != state.lv->get(i + 1).get_index()) { - state.lv->move(from, to); - break; - } - } - } -} - -static void run_lv_swap(RealmState& state, size_t ndx1, size_t ndx2) -{ - if (!state.lv) - return; - if (ndx1 < state.lv->size() && ndx2 < state.lv->size()) { - log("lv swap %zu %zu\n", ndx1, ndx2); - if (state.lv->get(ndx1).get_index() != state.lv->get(ndx2).get_index()) { - state.lv->swap(ndx1, ndx2); - // FIXME: swap() needs to produce moves so that a pair of swaps can - // be collapsed away. Currently it just marks the rows as modified. - state.modified.push_back(state.lv->get(ndx1).get_int(0)); - state.modified.push_back(state.lv->get(ndx2).get_int(0)); - } - } -} - -static void run_lv_remove(RealmState& state, size_t pos) -{ - if (!state.lv) - return; - if (pos < state.lv->size()) { - log("lv remove %zu\n", pos); - state.lv->remove(pos); - } -} - -static void run_lv_remove_target(RealmState& state, size_t pos) -{ - if (!state.lv) - return; - if (pos < state.lv->size()) { - log("lv target remove %zu\n", pos); - state.lv->remove_target_row(pos); - } -} - -static std::map(std::istream&)>> readers = { - // Row functions - {'a', make_reader(run_add)}, - {'c', make_reader(run_commit)}, - {'d', make_reader(run_delete)}, - {'m', make_reader(run_modify)}, - - // LinkView functions - {'i', make_reader(run_lv_insert)}, - {'s', make_reader(run_lv_set)}, - {'o', make_reader(run_lv_move)}, - {'w', make_reader(run_lv_swap)}, - {'r', make_reader(run_lv_remove)}, - {'t', make_reader(run_lv_remove_target)}, -}; - -template -static std::vector read_int_list(std::istream& input_stream) -{ - std::vector ret; - std::string line; - while (std::getline(input_stream, line) && !line.empty()) { - try { - ret.push_back(std::stoll(line)); - log("%lld\n", (long long)ret.back()); - } - catch (std::invalid_argument const&) { - // not an error - } - catch (std::out_of_range const&) { - // not an error - } - } - log("\n"); - return ret; -} - -CommandFile::CommandFile(std::istream& input) - : initial_values(read_int_list(input)) - , initial_list_indices(read_int_list(input)) -{ - if (!input.good()) - return; - - while (input.good()) { - char op = '\0'; - input >> op; - if (!input.good()) - break; - - auto it = readers.find(op); - if (it == readers.end()) - continue; - - auto fn = it->second(input); - if (!input.good()) - return; - commands.push_back(std::move(fn)); - } -} - -void CommandFile::import(RealmState& state) -{ - auto& table = state.table; - - state.realm.begin_transaction(); - - table.clear(); - size_t ndx = table.add_empty_row(initial_values.size()); - for (auto value : initial_values) { - table.set_int(0, ndx, state.uid++); - table.set_int(1, ndx++, value); - } - - state.lv->clear(); - for (auto value : initial_list_indices) { - if (value < table.size()) - state.lv->add(value); - } - - state.realm.commit_transaction(); -} - -void CommandFile::run(RealmState& state) -{ - state.realm.begin_transaction(); - for (auto& command : commands) { - command(state); - } - state.realm.commit_transaction(); -} diff --git a/test/object-store/notifications-fuzzer/command_file.hpp b/test/object-store/notifications-fuzzer/command_file.hpp deleted file mode 100644 index a77062d6e14..00000000000 --- a/test/object-store/notifications-fuzzer/command_file.hpp +++ /dev/null @@ -1,56 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#include - -#include -#include -#include -#include - -namespace realm { -class Table; -class LinkView; -class Realm; -namespace _impl { -class RealmCoordinator; -} -} // namespace realm - -namespace fuzzer { -struct RealmState { - realm::Realm& realm; - realm::_impl::RealmCoordinator& coordinator; - - realm::Table& table; - realm::LinkViewRef lv; - int64_t uid; - std::vector modified; -}; - -struct CommandFile { - std::vector initial_values; - std::vector initial_list_indices; - std::vector> commands; - - CommandFile(std::istream& input); - - void import(RealmState& state); - void run(RealmState& state); -}; -} // namespace fuzzer \ No newline at end of file diff --git a/test/object-store/notifications-fuzzer/fuzz-sorted-linkview.cpp b/test/object-store/notifications-fuzzer/fuzz-sorted-linkview.cpp deleted file mode 100644 index f54078534b2..00000000000 --- a/test/object-store/notifications-fuzzer/fuzz-sorted-linkview.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#define FUZZ_SORTED 1 -#define FUZZ_LINKVIEW 1 -#include "fuzzer.cpp" diff --git a/test/object-store/notifications-fuzzer/fuzz-sorted-query.cpp b/test/object-store/notifications-fuzzer/fuzz-sorted-query.cpp deleted file mode 100644 index 7a719d20aff..00000000000 --- a/test/object-store/notifications-fuzzer/fuzz-sorted-query.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#define FUZZ_SORTED 1 -#define FUZZ_LINKVIEW 0 -#include "fuzzer.cpp" diff --git a/test/object-store/notifications-fuzzer/fuzz-unsorted-linkview.cpp b/test/object-store/notifications-fuzzer/fuzz-unsorted-linkview.cpp deleted file mode 100644 index a7f20380e14..00000000000 --- a/test/object-store/notifications-fuzzer/fuzz-unsorted-linkview.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#define FUZZ_SORTED 0 -#define FUZZ_LINKVIEW 1 -#include "fuzzer.cpp" diff --git a/test/object-store/notifications-fuzzer/fuzz-unsorted-query.cpp b/test/object-store/notifications-fuzzer/fuzz-unsorted-query.cpp deleted file mode 100644 index 18dcb45ede2..00000000000 --- a/test/object-store/notifications-fuzzer/fuzz-unsorted-query.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#define FUZZ_SORTED 0 -#define FUZZ_LINKVIEW 0 -#include "fuzzer.cpp" diff --git a/test/object-store/notifications-fuzzer/fuzzer.cpp b/test/object-store/notifications-fuzzer/fuzzer.cpp deleted file mode 100644 index 90f2e4f907b..00000000000 --- a/test/object-store/notifications-fuzzer/fuzzer.cpp +++ /dev/null @@ -1,303 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// -// Copyright 2016 Realm Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////// - -#include "command_file.hpp" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace realm; - -#ifndef FUZZ_SORTED -#define FUZZ_SORTED 0 -#endif - -#ifndef FUZZ_LINKVIEW -#define FUZZ_LINKVIEW 0 -#endif - -#define FUZZ_LOG 0 - -// Read from a fd until eof into a string -// Needs to use unbuffered i/o to work properly with afl -static void read_all(std::string& buffer, int fd) -{ - buffer.clear(); - size_t offset = 0; - while (true) { - buffer.resize(offset + 4096); - ssize_t bytes_read = read(fd, &buffer[offset], 4096); - if (bytes_read < 4096) { - buffer.resize(offset + bytes_read); - break; - } - offset += 4096; - } -} - -static Query query(fuzzer::RealmState& state) -{ -#if FUZZ_LINKVIEW - return state.table.where(state.lv); -#else - return state.table.where().greater(1, 100).less(1, 50000); -#endif -} - -static TableView tableview(fuzzer::RealmState& state) -{ - auto tv = query(state).find_all(); -#if FUZZ_SORTED - tv.sort({1, 0}, {true, true}); -#endif - return tv; -} - -// Apply the changes from the command file and then return whether a change -// notification should occur -static bool apply_changes(fuzzer::CommandFile& commands, fuzzer::RealmState& state) -{ - auto tv = tableview(state); -#if FUZZ_LOG - for (size_t i = 0; i < tv.size(); ++i) - fprintf(stderr, "pre: %lld\n", tv.get_int(0, i)); -#endif - - commands.run(state); - - auto tv2 = tableview(state); - if (tv.size() != tv2.size()) - return true; - - for (size_t i = 0; i < tv.size(); ++i) { -#if FUZZ_LOG - fprintf(stderr, "%lld %lld\n", tv.get_int(0, i), tv2.get_int(0, i)); -#endif - if (!tv.is_row_attached(i)) - return true; - if (tv.get_int(0, i) != tv2.get_int(0, i)) - return true; - if (find(begin(state.modified), end(state.modified), tv.get_int(0, i)) != end(state.modified)) - return true; - } - - return false; -} - -static auto verify(CollectionChangeIndices const& changes, std::vector values, fuzzer::RealmState& state) -{ - auto tv = tableview(state); - - // Apply the changes from the transaction log to our copy of the - // initial, using UITableView's batching rules (i.e. delete, then - // insert, then update) - auto it = util::make_reverse_iterator(changes.deletions.end()); - auto end = util::make_reverse_iterator(changes.deletions.begin()); - for (; it != end; ++it) { - values.erase(values.begin() + it->first, values.begin() + it->second); - } - - for (auto i : changes.insertions.as_indexes()) { - values.insert(values.begin() + i, tv.get_int(1, i)); - } - - if (values.size() != tv.size()) { - abort(); - } - - for (auto i : changes.modifications.as_indexes()) { - if (changes.insertions.contains(i)) - abort(); - values[i] = tv.get_int(1, i); - } - -#if FUZZ_SORTED - if (!std::is_sorted(values.begin(), values.end())) - abort(); -#endif - - for (size_t i = 0; i < values.size(); ++i) { - if (values[i] != tv.get_int(1, i)) { -#if FUZZ_LOG - fprintf(stderr, "%lld %lld\n", values[i], tv.get_int(1, i)); -#endif - abort(); - } - } - - return values; -} - -static void verify_no_op(CollectionChangeIndices const& changes, std::vector values, - fuzzer::RealmState& state) -{ - auto new_values = verify(changes, values, state); - if (!std::equal(begin(values), end(values), begin(new_values), end(new_values))) - abort(); -} - -static void test(Realm::Config const& config, SharedRealm& r, SharedRealm& r2, std::istream& input_stream) -{ - fuzzer::RealmState state = {*r, - *_impl::RealmCoordinator::get_existing_coordinator(r->config().path), - *r->read_group()->get_table("class_object"), - r->read_group()->get_table("class_linklist")->get_linklist(0, 0), - 0, - {}}; - - fuzzer::CommandFile command(input_stream); - if (command.initial_values.empty()) { - return; - } - command.import(state); - - fuzzer::RealmState state2 = { - *r2, - state.coordinator, - *r2->read_group()->get_table("class_object"), -#if FUZZ_LINKVIEW - r2->read_group()->get_table("class_linklist")->get_linklist(0, 0), -#else - {}, -#endif - state.uid, - {} - }; - -#if FUZZ_LINKVIEW && !FUZZ_SORTED - auto results = List(r, ObjectSchema(), state.lv); -#else - auto results = Results(r, ObjectSchema(), query(state)) -#if FUZZ_SORTED - .sort({{1, 0}, {true, true}}) -#endif - ; -#endif // FUZZ_LINKVIEW - - std::vector initial_values; - for (size_t i = 0; i < results.size(); ++i) - initial_values.push_back(results.get(i).get_int(1)); - - CollectionChangeIndices changes; - int notification_calls = 0; - auto token = results.add_notification_callback([&](CollectionChangeIndices c, std::exception_ptr err) { - if (notification_calls > 0 && c.empty()) - abort(); - changes = c; - ++notification_calls; - }); - - state.coordinator.on_change(); - r->notify(); - if (notification_calls != 1) { - abort(); - } - - bool expect_notification = apply_changes(command, state2); - state.coordinator.on_change(); - r->notify(); - - if (expect_notification) { - if (notification_calls != 2) - abort(); - verify(changes, initial_values, state); - } - else { - if (notification_calls == 2) - verify_no_op(changes, initial_values, state); - } -} - -int main(int argc, char** argv) -{ - std::ios_base::sync_with_stdio(false); - realm::disable_sync_to_disk(); - - Realm::Config config; - config.path = "fuzzer.realm"; - config.in_memory = true; - config.automatic_change_notifications = false; - - Schema schema{{"object", "", {{"id", PropertyTypeInt}, {"value", PropertyTypeInt}}}, - {"linklist", "", {{"list", PropertyTypeArray, "object"}}}}; - - config.schema = std::make_unique(schema); - unlink(config.path.c_str()); - - auto r = Realm::get_shared_realm(config); - auto r2 = Realm::get_shared_realm(config); - auto& coordinator = *_impl::RealmCoordinator::get_existing_coordinator(config.path); - - r->begin_transaction(); - r->read_group()->get_table("class_linklist")->add_empty_row(); - r->commit_transaction(); - - auto test_on = [&](auto& buffer) { - std::istringstream ss(buffer); - test(config, r, r2, ss); - if (r->is_in_transaction()) - r->cancel_transaction(); - r2->invalidate(); - coordinator.on_change(); - }; - - if (argc > 1) { - std::string buffer; - for (int i = 1; i < argc; ++i) { - int fd = open(argv[i], O_RDONLY); - if (fd < 0) - abort(); - read_all(buffer, fd); - close(fd); - - test_on(buffer); - } - unlink(config.path.c_str()); - return 0; - } - -#ifdef __AFL_HAVE_MANUAL_CONTROL - std::string buffer; - while (__AFL_LOOP(1000)) { - read_all(buffer, 0); - test_on(buffer); - } -#else - std::string buffer; - read_all(buffer, 0); - test_on(buffer); -#endif - - unlink(config.path.c_str()); - return 0; -} diff --git a/test/object-store/notifications-fuzzer/input-lv/0 b/test/object-store/notifications-fuzzer/input-lv/0 deleted file mode 100644 index cb6a3bd9912..00000000000 --- a/test/object-store/notifications-fuzzer/input-lv/0 +++ /dev/null @@ -1,38 +0,0 @@ -3 -100 -200 -400 -1000 -2000 -50 -80 -150 -180 -6000 -5000 -60000 - -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 - -a 500 -d 12 -c -m 11 10000 -a 800 -i 5 13 -s 3 8 -o 2 10 -w 1 6 -r 7 -t 11 diff --git a/test/object-store/notifications-fuzzer/input/0 b/test/object-store/notifications-fuzzer/input/0 deleted file mode 100644 index 675ab1573d4..00000000000 --- a/test/object-store/notifications-fuzzer/input/0 +++ /dev/null @@ -1,20 +0,0 @@ -3 -100 -200 -400 -1000 -2000 -50 -80 -150 -180 -6000 -5000 -60000 - - -a 500 -d 12 -c -m 11 10000 -a 800 diff --git a/test/object-store/notifications-fuzzer/input/1 b/test/object-store/notifications-fuzzer/input/1 deleted file mode 100644 index 1cbf4855b6b..00000000000 --- a/test/object-store/notifications-fuzzer/input/1 +++ /dev/null @@ -1,34 +0,0 @@ -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 - - -a 114 -a 115 -a 116 -a 117 -a 118 -a 119 -a 120 -a 121 -a 122 -c -m 4 200 -m 3 201 -m 2 202 -m 1 203 -m 5 203 -m 6 204 -m 7 205 -c -d 11 diff --git a/test/performance/.gitignore b/test/performance/.gitignore deleted file mode 100644 index 0835f5dc4f8..00000000000 --- a/test/performance/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/*.d -/*.o - -# Coverage data -/*.gcno -/*.gcda - -/performance -/performance-dbg -/performance-cov diff --git a/test/performance/matrix.cpp b/test/performance/matrix.cpp deleted file mode 100644 index 864de8ef761..00000000000 --- a/test/performance/matrix.cpp +++ /dev/null @@ -1,1208 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include "../util/timer.hpp" - -// #define ONLY_CN_TESTS -/************************************************************************************ - -// In Visual Studio, enable this matrix.cpp in compilation and disable test.cpp, else -// compilation will fail (two main() functions). - -***********************************************************************************/ - -using namespace realm; - -namespace { - -const size_t row_count = 250112; // should be divisible by 128 -const size_t rounds = 1000; - -// const size_t row_count = 128*10; // should be divisible by 128 -// const size_t rounds = 1; - -REALM_TABLE_11(TestTable, bits_0, Int, bits_1, Int, bits_2, Int, bits_4, Int, bits_8, Int, bits_16, Int, bits_32, Int, - bits_64, Int, short_str, String, long_str, String, enum_str, String) - - -test_util::Timer timer; - - -struct TestStruct { - bool field1; - bool field2; - int field3; - int field4; - int field5; - int field6; - int field7; - int64_t field8; - std::string field9; - std::string field10; - std::string field11; -}; - -class match1 { -public: - match1(bool target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field1 == m_target; - } - -private: - const bool m_target; -}; -class match2 { -public: - match2(bool target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field2 == m_target; - } - -private: - const bool m_target; -}; -class match3 { -public: - match3(int target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field3 == m_target; - } - -private: - const int m_target; -}; -class match4 { -public: - match4(int target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field4 == m_target; - } - -private: - const int m_target; -}; -class match5 { -public: - match5(int target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field5 == m_target; - } - -private: - const int m_target; -}; -class match6 { -public: - match6(int target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field6 == m_target; - } - -private: - const int m_target; -}; -class match7 { -public: - match7(int target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field7 == m_target; - } - -private: - const int m_target; -}; -class match8 { -public: - match8(int64_t target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field8 == m_target; - } - -private: - const int64_t m_target; -}; -class match9 { -public: - match9(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field9 == m_target; - } - -private: - const std::string& m_target; -}; -class match10 { -public: - match10(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field10 == m_target; - } - -private: - const std::string& m_target; -}; -class match11 { -public: - match11(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field11 == m_target; - } - -private: - const std::string& m_target; -}; -class match9n { -public: - match9n(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field9 != m_target; - } - -private: - const std::string& m_target; -}; -class match10n { -public: - match10n(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field10 != m_target; - } - -private: - const std::string& m_target; -}; -class match11n { -public: - match11n(const std::string& target) - : m_target(target) - { - } - bool operator()(const TestStruct& v) const - { - return v.field11 != m_target; - } - -private: - const std::string& m_target; -}; -class columns2 { -public: - columns2() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3; - } -}; -class columns3 { -public: - columns3() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3 && v.field4 == 15; - } -}; -class columns4 { -public: - columns4() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL; - } -}; -class columns5 { -public: - columns5() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL; - } -}; -class columns6 { -public: - columns6() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL && - v.field7 == 0x7FFFFFFFLL; - } -}; -class columns7 { -public: - columns7() {} - bool operator()(const TestStruct& v) const - { - return v.field2 == 1 && v.field3 == 3 && v.field4 == 15 && v.field5 == 0x7FLL && v.field6 == 0x7FFFLL && - v.field7 == 0x7FFFFFFFLL && v.field8 == 0x7FFFFFFFFFFFFFFFLL; - } -}; - -} // anonymous namespace - - -int main() -{ -#ifdef REALM_DEBUG - std::cout << "Running Debug Build\n"; -#else - std::cout << "Running Release Build\n"; -#endif - std::cout << " Row count: " << row_count << "\n"; - std::cout << " Rounds: " << rounds << "\n"; - std::cout << "\n"; - - -#ifndef ONLY_CN_TESTS - // Realm tests - { - TestTable table; - - // Build large table - for (size_t i = 0; i < row_count; ++i) { - std::stringstream ss; - - // Create short unique string - ss << "s" << i; - const std::string short_str = ss.str(); - - // Create long unique string - ss << " very long string..............."; - const std::string long_str = ss.str(); - - // Create strings that can be auto-enumerated - const std::string enum_str = (i % 2) ? "monday" : "tuesday"; - - table.add(0, 1, 3, 15, 0x7FLL, 0x7FFFLL, 0x7FFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL, short_str.c_str(), - long_str.c_str(), enum_str.c_str()); - } - table.add(0, 0, 0, 0, 0, 0, 0, 0, "bottom", "long bottom", "saturday"); - - table.optimize(); // auto-enumerate last string column - - // Search over integer columns - for (size_t i = 0; i < 8; ++i) { - // Do a search over entire column (sparse, only last value matches) - { - // Search with query engine - TestTable::Query q = table.where(); - if (i == 0) - q.bits_0.equal(1); - else if (i == 1) - q.bits_1.equal(0); - else if (i == 2) - q.bits_2.equal(0); - else if (i == 3) - q.bits_4.equal(0); - else if (i == 4) - q.bits_8.equal(0); - else if (i == 5) - q.bits_16.equal(0); - else if (i == 6) - q.bits_32.equal(0); - else if (i == 7) - q.bits_64.equal(0); - - const size_t expected = (i == 0) ? 0 : 1; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Sparse: " << timer << "\n"; - - // Search with column intrinsic functions - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = table.column().bits_0.count(1); - else if (i == 1) - res = table.column().bits_1.count(0); - else if (i == 2) - res = table.column().bits_2.count(0); - else if (i == 3) - res = table.column().bits_4.count(0); - else if (i == 4) - res = table.column().bits_8.count(0); - else if (i == 5) - res = table.column().bits_16.count(0); - else if (i == 6) - res = table.column().bits_32.count(0); - else if (i == 7) - res = table.column().bits_64.count(0); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Sparse2: " << timer << "\n"; - } - - // Do a search over entire column (all matches) - { - // Search with query engine - TestTable::Query q = table.where(); - if (i == 0) - q.bits_0.equal(0); - else if (i == 1) - q.bits_1.equal(1); - else if (i == 2) - q.bits_2.equal(3); - else if (i == 3) - q.bits_4.equal(15); - else if (i == 4) - q.bits_8.equal(0x7FLL); - else if (i == 5) - q.bits_16.equal(0x7FFFLL); - else if (i == 6) - q.bits_32.equal(0x7FFFFFFFLL); - else if (i == 7) - q.bits_64.equal(0x7FFFFFFFFFFFFFFFLL); - - size_t expected = row_count; - if (i == 0) - ++expected; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Many: " << timer << "\n"; - - // Search with column intrinsic functions - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = table.column().bits_0.count(0); - else if (i == 1) - res = table.column().bits_1.count(1); - else if (i == 2) - res = table.column().bits_2.count(3); - else if (i == 3) - res = table.column().bits_4.count(15); - else if (i == 4) - res = table.column().bits_8.count(0x7FLL); - else if (i == 5) - res = table.column().bits_16.count(0x7FFFLL); - else if (i == 6) - res = table.column().bits_32.count(0x7FFFFFFFLL); - else if (i == 7) - res = table.column().bits_64.count(0x7FFFFFFFFFFFFFFFLL); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Many2: " << timer << "\n"; - } - - // Do a sum over entire column (all matches) - { - TestTable::Query q = table.where(); - size_t expected; - if (i == 0) - expected = 0; - else if (i == 1) - expected = row_count * 1; - else if (i == 2) - expected = row_count * 3; - else if (i == 3) - expected = row_count * 15; - else if (i == 4) - expected = row_count * 0x7FLL; - else if (i == 5) - expected = row_count * 0x7FFFLL; - else if (i == 6) - expected = row_count * 0x7FFFFFFFLL; - else if (i == 7) - expected = row_count * 0x7FFFFFFFFFFFFFFFLL; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = q.bits_0.sum(); - else if (i == 1) - res = q.bits_1.sum(); - else if (i == 2) - res = q.bits_2.sum(); - else if (i == 3) - res = q.bits_4.sum(); - else if (i == 4) - res = q.bits_8.sum(); - else if (i == 5) - res = q.bits_16.sum(); - else if (i == 6) - res = q.bits_32.sum(); - else if (i == 7) - res = q.bits_64.sum(); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Sum: " << timer << "\n"; - } - - // Do a sum over entire column (all matches) - { - int64_t expected; - if (i == 0) - expected = 0; - else if (i == 1) - expected = row_count * 1; - else if (i == 2) - expected = row_count * 3; - else if (i == 3) - expected = row_count * 15; - else if (i == 4) - expected = row_count * 0x7FLL; - else if (i == 5) - expected = row_count * 0x7FFFLL; - else if (i == 6) - expected = row_count * 0x7FFFFFFFLL; - else if (i == 7) - expected = row_count * 0x7FFFFFFFFFFFFFFFLL; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - int64_t res; - if (i == 0) - res = table.column().bits_0.sum(); - else if (i == 1) - res = table.column().bits_1.sum(); - else if (i == 2) - res = table.column().bits_2.sum(); - else if (i == 3) - res = table.column().bits_4.sum(); - else if (i == 4) - res = table.column().bits_8.sum(); - else if (i == 5) - res = table.column().bits_16.sum(); - else if (i == 6) - res = table.column().bits_32.sum(); - else if (i == 7) - res = table.column().bits_64.sum(); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: Column " << i << ": Sum2: " << timer << "\n"; - } - } - - for (size_t k = 0; k < 2; ++k) { - const char* const run = k == 0 ? "String" : "Index"; - - for (size_t i = 0; i < 3; ++i) { - // ColumnDirect: Do a search over entire column (sparse, only last value matches) - { - const size_t expected = 1; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = table.column().short_str.count("bottom"); - else if (i == 1) - res = table.column().long_str.count("long bottom"); - else if (i == 2) - res = table.column().enum_str.count("saturday"); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: " << run << "Column c " << i << ": Sparse: " << timer << "\n"; - } - - // Query: Do a search over entire column (sparse, only last value matches) - { - TestTable::Query q = table.where(); - if (i == 0) - q.short_str.equal("bottom"); - else if (i == 1) - q.long_str.equal("long bottom"); - else if (i == 2) - q.enum_str.equal("saturday"); - - const size_t expected = 1; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: " << run << "Column q " << i << ": Sparse: " << timer << "\n"; - } - - // Do a search over entire column (many matches) - { - TestTable::Query q = table.where(); - if (i == 0) - q.short_str.not_equal("bottom"); - else if (i == 1) - q.long_str.not_equal("long bottom"); - else if (i == 2) - q.enum_str.not_equal("saturday"); - - const size_t expected = i == 2 ? row_count / 2 : row_count; - const size_t len = table.size(); - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = len - table.column().short_str.count("bottom"); - else if (i == 1) - res = len - table.column().long_str.count("long bottom"); - else if (i == 2) - res = table.column().enum_str.count("monday"); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: " << run << "Column c " << i << ": Many: " << timer << "\n"; - } - - // Query: Do a search over entire column (many matches) - { - TestTable::Query q = table.where(); - if (i == 0) - q.short_str.not_equal("bottom"); - else if (i == 1) - q.long_str.not_equal("long bottom"); - else if (i == 2) - q.enum_str.equal("monday"); // every second entry matches - - const size_t expected = i == 2 ? row_count / 2 : row_count; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: " << run << "Column q " << i << ": Many: " << timer << "\n"; - } - } - - // Set index on string columns for next run - table.column().short_str.set_index(); - table.column().long_str.set_index(); - table.column().enum_str.set_index(); - } - } -#endif - -#ifndef ONLY_CN_TESTS - // STL tests - { - std::vector table; - - - // Build large table - for (size_t i = 0; i < row_count; ++i) { - std::stringstream ss; - - // Create short unique string - ss << "s" << i; - const std::string short_str = ss.str(); - - // Create long unique string - ss << " very long string..............."; - const std::string long_str = ss.str(); - - // Create strings that can be auto-enumerated - const std::string enum_str = (i % 2) ? "monday" : "tuesday"; - - const TestStruct ts = { - 0, 1, 3, 15, 0x7FLL, 0x7FFFLL, 0x7FFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL, short_str, long_str, enum_str}; - table.push_back(ts); - } - const TestStruct ts2 = {0, 0, 0, 0, 0, 0, 0, 0, "bottom", "long bottom", "saturday"}; - table.push_back(ts2); - - // Search over integer columns - for (size_t i = 0; i < 8; ++i) { - // Do a search over entire column (sparse, only last value matches) - { - const size_t expected = (i == 0) ? 0 : 1; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = count_if(table.begin(), table.end(), match1(true)); - else if (i == 1) - res = count_if(table.begin(), table.end(), match2(false)); - else if (i == 2) - res = count_if(table.begin(), table.end(), match3(0)); - else if (i == 3) - res = count_if(table.begin(), table.end(), match4(0)); - else if (i == 4) - res = count_if(table.begin(), table.end(), match5(0)); - else if (i == 5) - res = count_if(table.begin(), table.end(), match6(0)); - else if (i == 6) - res = count_if(table.begin(), table.end(), match7(0)); - else if (i == 7) - res = count_if(table.begin(), table.end(), match8(0)); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: Column " << i << ": Sparse: " << timer << "\n"; - } - - // Do a search over entire column (all matches) - { - size_t expected = row_count; - if (i == 0) - ++expected; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = count_if(table.begin(), table.end(), match1(false)); - else if (i == 1) - res = count_if(table.begin(), table.end(), match2(true)); - else if (i == 2) - res = count_if(table.begin(), table.end(), match3(3)); - else if (i == 3) - res = count_if(table.begin(), table.end(), match4(15)); - else if (i == 4) - res = count_if(table.begin(), table.end(), match5(0x7FLL)); - else if (i == 5) - res = count_if(table.begin(), table.end(), match6(0x7FFFLL)); - else if (i == 6) - res = count_if(table.begin(), table.end(), match7(0x7FFFFFFFLL)); - else if (i == 7) - res = count_if(table.begin(), table.end(), match8(0x7FFFFFFFFFFFFFFFLL)); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: Column " << i << ": Many: " << timer << "\n"; - } - - // Do a sum over entire column (all matches) - { - timer.reset(); - for (size_t n = 0; n < rounds; ++n) { - int64_t expected; - if (i == 0) - expected = 0; - else if (i == 1) - expected = row_count * 1; - else if (i == 2) - expected = row_count * 3; - else if (i == 3) - expected = row_count * 15; - else if (i == 4) - expected = row_count * 0x7FLL; - else if (i == 5) - expected = row_count * 0x7FFFLL; - else if (i == 6) - expected = row_count * 0x7FFFFFFFLL; - else if (i == 7) - expected = row_count * 0x7FFFFFFFFFFFFFFFLL; - { - int64_t res = 0; - if (i == 0) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += (int)p->field1; - } - } - else if (i == 1) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += (int)p->field2; - } - } - else if (i == 2) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field3; - } - } - else if (i == 3) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field4; - } - } - else if (i == 4) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field5; - } - } - else if (i == 5) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field6; - } - } - else if (i == 6) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field7; - } - } - else if (i == 7) { - for (std::vector::const_iterator p = table.begin(); p != table.end(); ++p) { - res += p->field8; - } - } - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: Column " << i << ": Sum: " << timer << "\n"; - } - } - - for (size_t i = 0; i < 3; ++i) { - // Do a search over entire column (sparse, only last value matches) - { - const size_t expected = 1; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = count_if(table.begin(), table.end(), match9("bottom")); - else if (i == 1) - res = count_if(table.begin(), table.end(), match10("long bottom")); - else if (i == 2) - res = count_if(table.begin(), table.end(), match11("saturday")); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: StringColumn " << i << ": Sparse: " << timer << "\n"; - } - - // Do a search over entire column (all but last value matches) - { - const size_t expected = row_count; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - size_t res; - if (i == 0) - res = count_if(table.begin(), table.end(), match9n("bottom")); - else if (i == 1) - res = count_if(table.begin(), table.end(), match10n("long bottom")); - else if (i == 2) - res = count_if(table.begin(), table.end(), match11n("saturday")); - - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: StringColumn " << i << ": Many: " << timer << "\n"; - } - } - } - -#endif - - // Realm Multi-column tests - { - TestTable table; - - // Build large table - for (size_t i = 0; i < row_count; ++i) { - std::stringstream ss; - - // Create short unique string - ss << "s" << i; - const std::string short_str = ss.str(); - - // Create long unique string - ss << " very long string..............."; - const std::string long_str = ss.str(); - - // Create strings that can be auto-enumerated - const std::string enum_str = (i % 2) ? "monday" : "tuesday"; - - const int64_t v1 = (i % 2) ? 0 : 1; - const int64_t v2 = (i % 4) ? 0 : 3; - const int64_t v3 = (i % 8) ? 0 : 15; - const int64_t v4 = (i % 16) ? 0 : 0x7FLL; - const int64_t v5 = (i % 32) ? 0 : 0x7FFFLL; - const int64_t v6 = (i % 64) ? 0 : 0x7FFFFFFFLL; - const int64_t v7 = (i % 128) ? 0 : 0x7FFFFFFFFFFFFFFFLL; - - table.add(0, v1, v2, v3, v4, v5, v6, v7, short_str.c_str(), long_str.c_str(), enum_str.c_str()); - } - // table.add(0, 0, 0, 0, 0, 0, 0, 0, "bottom", "long bottom", "saturday"); - - table.optimize(); // auto-enumerate last string column - - // Search over two columns - { - TestTable::Query q = table.where().bits_1.equal(1).bits_2.equal(3); - const size_t expected = row_count / 4; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: c2: " << timer << "\n"; - } - - // Search over three columns - { - TestTable::Query q = table.where().bits_1.equal(1).bits_2.equal(3).bits_4.equal(15); - const size_t expected = row_count / 8; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: c3: " << timer << "\n"; - } - - // Search over four columns - { - TestTable::Query q = table.where().bits_1.equal(1).bits_2.equal(3).bits_4.equal(15).bits_8.equal(0x7FLL); - const size_t expected = row_count / 16; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: c4: " << timer << "\n"; - } - - // Search over five columns - { - TestTable::Query q = - table.where().bits_1.equal(1).bits_2.equal(3).bits_4.equal(15).bits_8.equal(0x7FLL).bits_16.equal( - 0x7FFFLL); - const size_t expected = row_count / 32; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error " << expected << " " << res << "\n"; - } - } - } - std::cout << "Realm: c5: " << timer << "\n"; - } - - // Search over six columns - { - TestTable::Query q = table.where() - .bits_1.equal(1) - .bits_2.equal(3) - .bits_4.equal(15) - .bits_8.equal(0x7FLL) - .bits_16.equal(0x7FFFLL) - .bits_32.equal(0x7FFFFFFFLL); - const size_t expected = row_count / 64; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: c6: " << timer << "\n"; - } - - // Search over six columns - { - TestTable::Query q = table.where() - .bits_1.equal(1) - .bits_2.equal(3) - .bits_4.equal(15) - .bits_8.equal(0x7FLL) - .bits_16.equal(0x7FFFLL) - .bits_32.equal(0x7FFFFFFFLL) - .bits_64.equal(0x7FFFFFFFFFFFFFFFLL); - const size_t expected = row_count / 128; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = q.count(); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "Realm: c7: " << timer << "\n"; - } - } - - // STL Multi-column tests - { - std::vector table; - - - // Build large table - for (size_t i = 0; i < row_count; ++i) { - std::stringstream ss; - - // Create short unique string - ss << "s" << i; - const std::string short_str = ss.str(); - - // Create long unique string - ss << " very long string..............."; - const std::string long_str = ss.str(); - - // Create strings that can be auto-enumerated - const std::string enum_str = (i % 2) ? "monday" : "tuesday"; - - const bool v1 = (i % 2) ? false : true; - const int v2 = (i % 4) ? 0 : 0x3; - const int v3 = (i % 8) ? 0 : 0xF; - const int v4 = (i % 16) ? 0 : 0x7F; - const int v5 = (i % 32) ? 0 : 0x7FFF; - const int v6 = (i % 64) ? 0 : 0x7FFFFFFF; - const int64_t v7 = (i % 128) ? 0 : 0x7FFFFFFFFFFFFFFFLL; - - const TestStruct ts = {0, v1, v2, v3, v4, v5, v6, v7, short_str, long_str, enum_str}; - table.push_back(ts); - } - const TestStruct ts2 = {0, 0, 0, 0, 0, 0, 0, 0, "bottom", "long bottom", "saturday"}; - table.push_back(ts2); - - // Search over two columns - { - const size_t expected = row_count / 4; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns2()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c2: " << timer << "\n"; - } - - // Search over three columns - { - const size_t expected = row_count / 8; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns3()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c3: " << timer << "\n"; - } - - // Search over four columns - { - const size_t expected = row_count / 16; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns4()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c4: " << timer << "\n"; - } - - // Search over five columns - { - const size_t expected = row_count / 32; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns5()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c5: " << timer << "\n"; - } - - // Search over six columns - { - const size_t expected = row_count / 64; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns6()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c6: " << timer << "\n"; - } - - // Search over seven columns - { - const size_t expected = row_count / 128; - - timer.reset(); - { - for (size_t n = 0; n < rounds; ++n) { - const size_t res = count_if(table.begin(), table.end(), columns7()); - if (res != expected) { - std::cout << "error\n"; - } - } - } - std::cout << "STL: c7: " << timer << "\n"; - } - } - - return 0; -} diff --git a/test/protocol_compat/.gitignore b/test/protocol_compat/.gitignore deleted file mode 100644 index c866578d73f..00000000000 --- a/test/protocol_compat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/fetches diff --git a/test/protocol_compat/test.py b/test/protocol_compat/test.py deleted file mode 100644 index 12d54e77b86..00000000000 --- a/test/protocol_compat/test.py +++ /dev/null @@ -1,272 +0,0 @@ -core_git_remote = 'git@github.com:realm/realm-core.git' -sync_git_remote = 'git@github.com:realm/realm-sync.git' - -import sys -import os -import subprocess -import tempfile -import shutil -import time -import threading - -root_dir = os.path.dirname(sys.argv[0]) - -cmake = os.environ.get('CMAKE', 'cmake') -cmake_generator = os.environ.get('CMAKE_GENERATOR', 'Ninja') -make = os.environ.get('MAKE', 'ninja') -cmake_build_type = os.environ.get('CMAKE_BUILD_TYPE', 'Debug') -build_dir_name = os.environ.get('REALM_BUILD_DIR', - {'Release': 'build.release', - 'Debug': 'build.debug'}.get(cmake_build_type, 'build')) -cmd_prefix = os.environ.get('CMD_PREFIX', '').split() - -print('cmake=%s' % (cmake,)) -print('cmake_generator=%s' % (cmake_generator,)) -print('make=%s' % (make,)) -print('cmake_build_type=%s' % (cmake_build_type,)) -print('build_dir_name=%s' % (build_dir_name,)) -print('cmd_prefix=%s' % (cmd_prefix,)) - -def ensure_dir(path): - if not os.path.isdir(path): - os.makedirs(path) - -class TempDir: - def __init__(self): - self._path = tempfile.mkdtemp() - def __enter__(self): - return self._path - def __exit__(self, type, value, traceback): - shutil.rmtree(self._path) - return False # Reraise exception - -def run_subprocess(args, cwd = None): - proc = subprocess.Popen(args, cwd = cwd) - exit_status = proc.wait() - if exit_status != 0: - raise Exception('Execution of %s failed with exit status %s' % (args, exit_status)) - -def fetch(repo_name, git_remote, revision): - repo_parent_dir = root_dir + '/fetches/' + repo_name - repo_dir = repo_parent_dir + '/' + revision - if not os.path.exists(repo_dir): - print('================> Fetching %s@%s' % (repo_name, revision)) - run_subprocess(['git', 'clone', '--quiet', '--branch', revision, '--recurse-submodules', - git_remote, repo_dir]) - return repo_dir - -def fetch_core(revision): - return fetch('core', core_git_remote, revision) - -def fetch_sync(revision): - return fetch('sync', sync_git_remote, revision) - -def read_core_revision(repo_dir): - prefix = 'REALM_CORE_VERSION=' - path = repo_dir + '/dependencies.list' - file = open(path) - for line in file: - if line.startswith(prefix): - version = line[len(prefix):].strip() - tag = 'v' + version - return tag - raise ValueError('Failed to find Realm Core version in %s' % (path,)) - -def build_core(revision): - repo_dir = fetch_core(revision) - build_dir = repo_dir + '/' + build_dir_name - print('================> Building core@%s' % (revision,)) - ensure_dir(build_dir) - run_subprocess(cmd_prefix + - [cmake, '-G', cmake_generator, - '-D', 'REALM_NO_TESTS=1', - '-D', 'CMAKE_BUILD_TYPE=' + cmake_build_type, - '..'], cwd = build_dir) - run_subprocess(cmd_prefix + [make], cwd = build_dir) - return build_dir - -def build_sync(revision): - if revision: - repo_dir = fetch_sync(revision) - core_revision = read_core_revision(repo_dir) - core_build_dir = build_core(core_revision) - print('================> Building sync@%s' % (revision,)) - else: - repo_dir = root_dir + '/../..' - core_build_dir = os.environ.get('REALM_CORE_BUILDTREE', - repo_dir + '/../realm-core/' + build_dir_name) - print('================> Building sync') - openssl_root_dir = os.environ.get('OPENSSL_ROOT_DIR', '/usr') - build_dir = repo_dir + '/' + build_dir_name - core_build_dir_2 = os.path.abspath(core_build_dir) - ensure_dir(build_dir) - run_subprocess(cmd_prefix + - [cmake, '-G', cmake_generator, - '-D', 'OPENSSL_ROOT_DIR=' + openssl_root_dir, - '-D', 'REALM_CORE_BUILDTREE=' + core_build_dir_2, - '-D', 'CMAKE_BUILD_TYPE=' + cmake_build_type, - '..'], cwd = build_dir) - run_subprocess(cmd_prefix + [make], cwd = build_dir) - return build_dir - -def build_server(revision = None): - build_dir = build_sync(revision) - suffix = '-dbg' if cmake_build_type == 'Debug' else '' - return build_dir + '/src/realm/realm-sync-worker' + suffix - -def build_client(revision = None): - build_dir = build_sync(revision) - return build_dir + '/test/test-client' - -class Server: - def __init__(self, exec_path, server_dir): - listen_port = 0 # Assign an unused port - args = [ exec_path, - '-r', server_dir, - '-k', root_dir + '/../test_pubkey.pem', - '--log-level', 'info', - '--listen-port', str(listen_port) ] - self._proc = subprocess.Popen(args, stderr = subprocess.PIPE) - self._listen_port_semaphore = threading.Semaphore(0) - self._errors_seen = False - self._log_scanning_thread = threading.Thread(target = lambda: self._scan_log()) - self._log_scanning_thread.start() - self._listen_port_semaphore.acquire() - def __enter__(self): - return self - def __exit__(self, type, value, traceback): - self.kill() - return False # Reraise exception - def get_listen_port(self): - return self._listen_port - def kill(self): - self._proc.kill() - self._proc.wait() - self._log_scanning_thread.join() - if self._errors_seen: - raise Exception('Errors were reported by server') - def _scan_log(self): - listening_prefix = 'Listening on ' - error_prefix = 'ERROR: ' - have_port = False - while True: - line = self._proc.stderr.readline() - if not line: - break - line_2 = line.decode('utf-8') - if not have_port: - if line_2.startswith(listening_prefix): - rest = line_2[len(listening_prefix) :] - pos = rest.index(' ') - endpoint = rest[0 : pos] - pos = endpoint.rindex(':') - port = int(endpoint[pos + 1 :]) - self._listen_port = port - self._listen_port_semaphore.release() - have_port = True - if line_2.startswith(error_prefix): - self._errors_seen = True - sys.stderr.write('Server: ' + line_2) - -class Client: - def __init__(self, exec_path, realm_path, virtual_path, listen_port, extra_args): - args = [ exec_path, - realm_path, - 'realm://localhost:%s%s' % (listen_port, virtual_path), - '--abort-on-error', 'always' ] - self._proc = subprocess.Popen(args + extra_args, stderr = subprocess.PIPE) - self._log_scanning_thread = threading.Thread(target = lambda: self._scan_log()) - self._log_scanning_thread.start() - def __enter__(self): - return self - def __exit__(self, type, value, traceback): - self.wait() - return False # Reraise exception - def wait(self): - exit_status = self._proc.wait() - self._log_scanning_thread.join() - if exit_status != 0: - raise Exception('Execution of client failed with exit status %s' % (exit_status,)) - def _scan_log(self): - while True: - line = self._proc.stderr.readline() - if not line: - break - line_2 = line.decode('utf-8') - sys.stderr.write('Client: ' + line_2) - -def run_client(exec_path, realm_path, virtual_path, listen_port, extra_args): - with Client(exec_path, realm_path, virtual_path, listen_port, extra_args): - pass - -def upload(exec_path, realm_path, virtual_path, listen_port, num_blobs = 1): - extra_args = [ '--num-transacts', '1', - '--transact-period', '0', - '--num-blobs', "%d" % num_blobs ] - run_client(exec_path, realm_path, virtual_path, listen_port, extra_args) - -def download(exec_path, realm_path, virtual_path, listen_port): - extra_args = [] - run_client(exec_path, realm_path, virtual_path, listen_port, extra_args) - -# Test a scenario that triggered a bug -# (https://jira.mongodb.org/browse/SYNC-14) in version Sync 4.7.2. -def double_download_with_protocol_28(): - server_exec_path = build_server() # Local version - client_exec_path_1 = build_client() # Local version - client_exec_path_2 = build_client('v4.6.4') # Protocol version 28 - print('================> TEST: double_download_with_protocol_28') - with TempDir() as server_dir: - with Server(server_exec_path, server_dir) as server: - listen_port = server.get_listen_port() - with TempDir() as client_dir: - writer_path = os.path.join(client_dir, 'writer.realm') - reader_path = os.path.join(client_dir, 'reader.realm') - upload(client_exec_path_1, writer_path, '/test', listen_port) - download(client_exec_path_2, reader_path, '/test', listen_port) - upload(client_exec_path_1, writer_path, '/test', listen_port) - download(client_exec_path_2, reader_path, '/test', listen_port) -double_download_with_protocol_28() - -# Test a scenario that triggered a bug -# (https://jira.mongodb.org/browse/SYNC-27) in version Sync 4.7.4. -def double_download_with_sync_4_6_4_then_upgrade_server(): - server_exec_path_1 = build_server('v4.6.4') # Protocol version 28 - server_exec_path_2 = build_server() # Local version - client_exec_path = build_client('v4.6.4') # Protocol version 28 - print('================> TEST: double_download_with_sync_4_6_4_then_upgrade_server') - with TempDir() as client_dir: - writer_path = os.path.join(client_dir, 'writer.realm') - reader_path = os.path.join(client_dir, 'reader.realm') - with TempDir() as server_dir: - with Server(server_exec_path_1, server_dir) as server: - listen_port = server.get_listen_port() - upload(client_exec_path, writer_path, '/test', listen_port) - download(client_exec_path, reader_path, '/test', listen_port) - upload(client_exec_path, writer_path, '/test', listen_port) - with Server(server_exec_path_2, server_dir) as server: - listen_port = server.get_listen_port() - download(client_exec_path, reader_path, '/test', listen_port) -double_download_with_sync_4_6_4_then_upgrade_server() - -def double_download_with_sync_4_6_4_then_upgrade_both(): - server_exec_path_1 = build_server('v4.6.4') # Protocol version 28 - server_exec_path_2 = build_server() # Local version - client_exec_path_1 = build_client('v4.6.4') # Protocol version 28 - client_exec_path_2 = build_client() # Local version - print('================> TEST: double_download_with_sync_4_6_4_then_upgrade_both') - with TempDir() as client_dir: - writer_path = os.path.join(client_dir, 'writer.realm') - reader_path = os.path.join(client_dir, 'reader.realm') - with TempDir() as server_dir: - with Server(server_exec_path_1, server_dir) as server: - listen_port = server.get_listen_port() - upload(client_exec_path_1, writer_path, '/test', listen_port) - download(client_exec_path_1, reader_path, '/test', listen_port) - upload(client_exec_path_1, writer_path, '/test', listen_port) - with Server(server_exec_path_2, server_dir) as server: - listen_port = server.get_listen_port() - download(client_exec_path_2, reader_path, '/test', listen_port) -double_download_with_sync_4_6_4_then_upgrade_both() - -print('================> All tests passed') diff --git a/test/simple-connection/.gitignore b/test/simple-connection/.gitignore deleted file mode 100644 index 757e9089ca3..00000000000 --- a/test/simple-connection/.gitignore +++ /dev/null @@ -1 +0,0 @@ -simple-connection diff --git a/test/simple-connection/main.cpp b/test/simple-connection/main.cpp deleted file mode 100644 index 6c955723480..00000000000 --- a/test/simple-connection/main.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -char time_buffer[1000]; - -void get_time(char* time_buffer) -{ - time_t rawtime; - time(&rawtime); - - struct tm* time_info; - time_info = localtime(&rawtime); - - sprintf(time_buffer, "%s", asctime(time_info)); -} - -int connect_to_server() -{ - int sock_fd = socket(PF_INET, SOCK_STREAM, 0); - - if (sock_fd == -1) { - printf("error in socket: %s\n", strerror(errno)); - return -1; - } - - struct sockaddr_in sa; - - const char* ip_addr = "10.60.101.153"; - uint16_t port = 27800; - - memset(&sa, 0, sizeof(struct sockaddr_in)); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = inet_addr(ip_addr); - sa.sin_port = htons(port); - - int rc = connect(sock_fd, (struct sockaddr*)&sa, sizeof(sa)); - if (rc == -1) { - printf("Error in connect: %s\n", strerror(errno)); - return -2; - } - - const char request[] = "GET /realm-object-server HTTP/1.1\r\n" - "Host: lt.sync.realmlab.net\r\n" - "Upgrade: websocket\r\n" - "Connection: Upgrade\r\n" - "Sec-WebSocket-Key: EYRk0diT0W7xxd/jbitJJw==\r\n" - "Sec-WebSocket-Version: 13\r\n" - "Sec-WebSocket-Protocol: io.realm.protocol\r\n" - "\r\n"; - - ssize_t bytes_written = write(sock_fd, request, sizeof(request) - 1); - if (bytes_written != sizeof(request) - 1) { - close(sock_fd); - return -3; - } - - const char* exp_resp_head = "HTTP/1.1 101 Switching Protocols\r\n"; - const size_t exp_resp_head_size = sizeof(exp_resp_head) - 1; - - char response[1000]; - ssize_t bytes_read = read(sock_fd, response, 1000); - if (bytes_read < exp_resp_head_size) { - close(sock_fd); - return -4; - } - // printf("bytes read = %zd\n\n", bytes_read); - // printf("%s\n", response); - - if (strncmp(response, exp_resp_head, exp_resp_head_size) != 0) { - printf("incorrect response\n"); - close(sock_fd); - return -4; - } - - // rc = close(sock_fd); - // if (rc == -1) { - // printf("Error in close: %s\n", strerror(errno)); - // return -5; - //} - - return sock_fd; -} - -int multiple_connect(int nconn) -{ - for (int i = 0; i < nconn; ++i) { - int fd = connect_to_server(); - if (fd < 0) { - printf("pid = %d, Connection error, fd = %d\n", getpid(), fd); - return 1; - } - if (i % 100 == 0) { - get_time(time_buffer); - printf("pid = %d, i = %d, fd = %d time = %s", getpid(), i, fd, time_buffer); - } - } - - get_time(time_buffer); - printf("pid = %d, goes to sleep, time = %s", getpid(), time_buffer); - sleep(1000000); - - return 0; -} - -int main(int argc, char** argv) -{ - int nproc = atoi(argv[1]); - int nconn = atoi(argv[2]); - - for (int i = 0; i < nproc; ++i) { - pid_t pid = fork(); - if (pid == 0) { - multiple_connect(nconn); - return 1; - } - } - - printf("parent, pid = %d, goes to sleep\n", getpid()); - sleep(1000000); - - return 0; -} diff --git a/test/test_client_reset_query_based.cpp b/test/test_client_reset_query_based.cpp deleted file mode 100644 index ff59b723d3f..00000000000 --- a/test/test_client_reset_query_based.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#include -#include - -#include -#include - -#include "test.hpp" -#include "sync_fixtures.hpp" -#include "util/semaphore.hpp" -#include "util/compare_groups.hpp" - -using namespace realm; -using namespace realm::sync; -using namespace realm::test_util; -using namespace realm::fixtures; - -namespace { - -using ErrorInfo = SessionErrorInfo; - -// FIXME: Rewrite this test without QBS -TEST_IF(ClientResetQueryBased_1, false) -{ - TEST_DIR(dir_1); // The original server dir. - TEST_DIR(dir_2); // The backup dir. - SHARED_GROUP_TEST_PATH(path_1); // The writer. - SHARED_GROUP_TEST_PATH(path_2); // The resetting client. - TEST_DIR(metadata_dir); // The metadata directory used by the resetting client. - - util::Logger& logger = test_context.logger; - - const std::string ref_path = "/data"; - const std::string partial_path = "/data/__partial/test/1"; - - std::string ref_path_1, partial_path_1, ref_path_2, partial_path_2; - - // First we make a changeset and upload it to the reference Realm. - // we also create a partial client with a query and a query result. - { - ClientServerFixture fixture(dir_1, test_context); - fixture.start(); - ref_path_1 = fixture.map_virtual_to_real_path(ref_path); - partial_path_1 = fixture.map_virtual_to_real_path(partial_path); - - // Create the data and upload it to the reference Realm. - { - std::unique_ptr history = make_client_replication(); - DBRef sg = DB::create(*history, path_1); - Session session = fixture.make_session(path_1); - fixture.bind_session(session, ref_path); - - WriteTransaction wt{sg}; - TableRef table = create_table(wt, "class_values"); - auto col_ndx = table->add_column(type_Int, "value"); - for (int i = 0; i < 3; ++i) { - create_object(wt, *table).set(col_ndx, 1000 + i * 100); - } - session.nonsync_transact_notify(wt.commit()); - session.wait_for_upload_complete_or_client_stopped(); - } - - // Create a partial client and add a query. - { - std::unique_ptr history = make_client_replication(); - DBRef sg = DB::create(*history, path_2); - Session session = fixture.make_session(path_2); - fixture.bind_session(session, partial_path); - - session.wait_for_download_complete_or_client_stopped(); - { - WriteTransaction wt{sg}; - Group& group = wt.get_group(); - TableRef table = group.get_table("class_values"); - CHECK(table); - - // Create the query - TableRef result_sets = wt.get_table(g_partial_sync_result_sets_table_name); - CHECK(result_sets); - ColKey col_key_query = result_sets->get_column_key("query"); - ColKey col_key_matches_property = result_sets->get_column_key("matches_property"); - ColKey col_key_status = result_sets->get_column_key("status"); - CHECK(col_key_query); - CHECK(col_key_matches_property); - CHECK(col_key_status); - result_sets->add_column_list(*table, "values"); - Obj res = create_object(wt, *result_sets); - res.set(col_key_matches_property, "values"); - res.set(col_key_query, "value = 1100"); - session.nonsync_transact_notify(wt.commit()); - } - session.wait_for_upload_complete_or_client_stopped(); - session.wait_for_download_complete_or_client_stopped(); - { - ReadTransaction rt{sg}; - const Group& group = rt.get_group(); - ConstTableRef table = group.get_table("class_values"); - CHECK(table); - CHECK_EQUAL(table->size(), 1); - } - } - } - - // Get the real paths of the backup. - { - ClientServerFixture fixture(dir_2, test_context); - fixture.start(); - ref_path_2 = fixture.map_virtual_to_real_path(ref_path); - partial_path_2 = fixture.map_virtual_to_real_path(partial_path); - } - - // The server is shut down. We make a backup of the server Realms. - logger.debug("ref_path_1 = %1, partial_path_1 = %2, " - "ref_path_2 = %3, partial_path_2 = %4", - ref_path_1, partial_path_1, ref_path_2, partial_path_2); - // util::File::copy(ref_path_1, ref_path_2); - // util::File::copy(partial_path_1, partial_path_2); - - - // Start a server and let the partial client add another query. - { - } - - - // - // - // // Make the second changeset in the original and have a client download it - // // all. - // { - // ClientServerFixture fixture(dir_1, test_context); - // fixture.start(); - // real_path_1 = fixture.map_virtual_to_real_path(server_path); - // - // std::unique_ptr history = make_client_replication(); - // DBRef sg = DB::create(*history, path_1); - // Session session = fixture.make_session(path_1); - // fixture.bind_session(session, server_path); - // - // WriteTransaction wt {sg}; - // Group& group = wt.get_group(); - // TableRef table = group.get_table("class_table"); - // size_t row_ndx = create_object(group, *table); - // CHECK_EQUAL(row_ndx, 1); - // table->set_int(col_ndx, row_ndx, 456); - // session.nonsync_transact_notify(wt.commit()); - // session.wait_for_upload_complete_or_client_stopped(); - // - // Session session_2 = fixture.make_session(path_2); - // fixture.bind_session(session_2, server_path); - // session_2.wait_for_download_complete_or_client_stopped(); - // } - // - // // Check the content in path_2. - // { - // std::unique_ptr history = make_client_replication(); - // DBRef sg = DB::create(*history, path_2); - // ReadTransaction rt {sg}; - // const Group& group = rt.get_group(); - // ConstTableRef table = group.get_table("class_table"); - // CHECK(table); - // CHECK_EQUAL(table->size(), 2); - // CHECK_EQUAL(table->get_int(col_ndx, 0), 123); - // CHECK_EQUAL(table->get_int(col_ndx, 1), 456); - // } - // - // // Start the server from dir_2 and connect with the client 2. - // // We expect an error of type 209, "Bad server version". - // { - // ClientServerFixture fixture(dir_2, test_context); - // fixture.start(); - // - // // The session that receives an error. - // { - // BowlOfStonesSemaphore bowl; - // auto listener = [&](ConnectionState state, const ErrorInfo* error_info) { - // if (state != ConnectionState::disconnected) - // return; - // REALM_ASSERT(error_info); - // std::error_code ec = error_info->error_code; - // CHECK_EQUAL(ec, sync::ProtocolError::bad_server_version); - // bowl.add_stone(); - // }; - // - // Session session = fixture.make_session(path_2); - // session.set_connection_state_change_listener(listener); - // fixture.bind_session(session, server_path); - // bowl.get_stone(); - // } - // - // // The session that performs client reset. - // // The Realm will be opened by a user while the reset takes place. - // { - // std::unique_ptr history = make_client_replication(); - // DBRef sg = DB::create(*history, path_2); - // ReadTransaction rt {sg}; - // const Group& group = rt.get_group(); - // ConstTableRef table = group.get_table("class_table"); - // CHECK_EQUAL(table->size(), 2); - // - // Session::Config session_config; - // { - // Session::Config::ClientReset client_reset_config; - // client_reset_config.metadata_dir = std::string(metadata_dir); - // session_config.client_reset_config = client_reset_config; - // } - // Session session = fixture.make_session(path_2, session_config); - // fixture.bind_session(session, server_path); - // session.wait_for_download_complete_or_client_stopped(); - // } - // } - // - // // Check the content in path_2. There should only be one row now. - // { - // std::unique_ptr history = make_client_replication(); - // DBRef sg = DB::create(*history, path_2); - // ReadTransaction rt {sg}; - // const Group& group = rt.get_group(); - // ConstTableRef table = group.get_table("class_table"); - // CHECK(table); - // CHECK_EQUAL(table->size(), 1); - // CHECK_EQUAL(table->get_int(col_ndx, 0), 123); - // } -} - -} // unnamed namespace diff --git a/test/test_optional.cpp b/test/test_optional.cpp deleted file mode 100644 index 052ad8ff1fa..00000000000 --- a/test/test_optional.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#include "testsettings.hpp" - -#include - -#include "test.hpp" - -using namespace realm::util; - -TEST(Optional_DefaultConstructor) -{ - Optional x{}; - CHECK(!bool(x)); -} - -TEST(Optional_NoneConstructor) -{ - Optional x{realm::none}; - CHECK(!bool(x)); -} - -TEST(Optional_ValueConstructor) -{ - Optional a{"foo"}; - CHECK(bool(a)); -} - -TEST(Optional_MoveConstructor) -{ - Optional a{"foo"}; - Optional b{std::move(a)}; - CHECK(bool(a)); - CHECK(bool(b)); - CHECK_EQUAL(*a, ""); - CHECK_EQUAL(*b, "foo"); -} - -TEST(Optional_CopyConstructor) -{ - Optional a{"foo"}; - Optional b{a}; - CHECK(bool(a)); - CHECK(bool(b)); - CHECK_EQUAL(*a, "foo"); - CHECK_EQUAL(*b, "foo"); -} - -TEST(Optional_MoveValueConstructor) -{ - std::string a = "foo"; - Optional b{std::move(a)}; - CHECK(bool(b)); - CHECK_EQUAL(*b, "foo"); - CHECK_EQUAL(a, ""); -} - -TEST(Optional_CopyAssignment) -{ - Optional a{"foo"}; - Optional b; - b = a; - CHECK(bool(a)); - CHECK(bool(b)); - CHECK_EQUAL(*a, "foo"); - CHECK_EQUAL(*b, "foo"); - - Optional c{"foo"}; - Optional d{"bar"}; - d = c; - CHECK(bool(c)); - CHECK(bool(d)); - CHECK_EQUAL(*c, "foo"); - CHECK_EQUAL(*d, "foo"); - - Optional e; - Optional f{"foo"}; - f = e; - CHECK(!bool(e)); - CHECK(!bool(f)); -} - -TEST(Optional_MoveAssignment) -{ - Optional a{"foo"}; - Optional b; - b = std::move(a); - CHECK(bool(a)); - CHECK(bool(b)); - CHECK_EQUAL(*b, "foo"); - - Optional c{"foo"}; - Optional d{"bar"}; - d = std::move(c); - CHECK(bool(c)); - CHECK(bool(d)); - CHECK_EQUAL(*d, "foo"); - - Optional e; - Optional f{"foo"}; - f = std::move(e); - CHECK(!bool(e)); - CHECK(!bool(f)); -} - -TEST(Optional_ValueAssignment) -{ - Optional o; - o = std::string{"foo"}; - CHECK(bool(o)); - CHECK_EQUAL(*o, "foo"); - - o = std::string{"bar"}; - CHECK(bool(o)); - CHECK_EQUAL(*o, "bar"); -} - -namespace { - -struct SetBooleanOnDestroy { - bool& m_b; - explicit SetBooleanOnDestroy(bool& b) - : m_b(b) - { - } - ~SetBooleanOnDestroy() - { - m_b = true; - } -}; - -} // unnamed namespace - -TEST(Optional_Destructor) -{ - bool b = false; - { - Optional x{SetBooleanOnDestroy(b)}; - } - CHECK(b); -} - -TEST(Optional_DestroyOnAssignNone) -{ - bool b = false; - { - Optional x{SetBooleanOnDestroy(b)}; - x = realm::none; - CHECK(b); - } - CHECK(b); -} - -namespace { - -/// See: -/// http://www.boost.org/doc/libs/1_57_0/libs/optional/doc/html/boost_optional/dependencies_and_portability/optional_reference_binding.html - -const int global_i = 0; - -struct TestingReferenceBinding { - TestingReferenceBinding(const int& ii) - { - static_cast(ii); - REALM_ASSERT(&ii == &global_i); - } - - void operator=(const int& ii) - { - static_cast(ii); - REALM_ASSERT(&ii == &global_i); - } - - void operator=(int&&) - { - REALM_ASSERT(false); - } -}; - -} // unnamed namespace - -TEST(Optional_ReferenceBinding) -{ - const int& iref = global_i; - CHECK_EQUAL(&iref, &global_i); - TestingReferenceBinding ttt = global_i; - ttt = global_i; - TestingReferenceBinding ttt2 = iref; - ttt2 = iref; -} - -TEST(Optional_ValueDoesntGenerateWarning) -{ - // Shouldn't generate any warnings: - const Optional i{1}; - CHECK(*i); -} - -TEST(Optional_ConstExpr) -{ - // Should compile: - constexpr Optional a; - constexpr Optional b{none}; - constexpr Optional c{1}; - CHECK_EQUAL(bool(a), false); - CHECK_EQUAL(bool(c), true); - constexpr int d = *c; - CHECK_EQUAL(1, d); - constexpr bool e = bool(Optional{1}); - CHECK_EQUAL(true, e); - constexpr bool f = bool(Optional{none}); - CHECK_EQUAL(false, f); - constexpr int g = b.value_or(1234); - CHECK_EQUAL(1234, g); -} - -// Disabled for compliance with std::optional -// TEST(Optional_VoidIsEquivalentToBool) -// { -// auto a = some(); -// CHECK_EQUAL(sizeof(a), sizeof(bool)); -// CHECK(a); -// Optional b = none; -// CHECK_EQUAL(sizeof(b), sizeof(bool)); -// CHECK(!b); -// } diff --git a/test/test_table.cpp b/test/test_table.cpp index 0061c55f3c4..80df42e1824 100644 --- a/test/test_table.cpp +++ b/test/test_table.cpp @@ -238,48 +238,6 @@ struct value_copier { }; } // namespace -#ifdef JAVA_MANY_COLUMNS_CRASH - -REALM_TABLE_3(SubtableType, year, Int, daysSinceLastVisit, Int, conceptId, String) - -REALM_TABLE_7(MainTableType, patientId, String, gender, Int, ethnicity, Int, yearOfBirth, Int, yearOfDeath, Int, - zipCode, String, events, Subtable) - -TEST(Table_ManyColumnsCrash2) -{ - // Trying to reproduce Java crash. - for (int a = 0; a < 10; a++) { - Group group; - - MainTableType::Ref mainTable = group.add_table("PatientTable"); - TableRef dynPatientTable = group.add_table("PatientTable"); - dynPatientTable->add_empty_row(); - - for (int counter = 0; counter < 20000; counter++) { -#if 0 - // Add row to subtable through typed interface - SubtableType::Ref subtable = mainTable[0].events->get_table_ref(); - REALM_ASSERT(subtable->is_attached()); - subtable->add(0, 0, ""); - REALM_ASSERT(subtable->is_attached()); - -#else - // Add row to subtable through dynamic interface. This mimics Java closest - TableRef subtable2 = dynPatientTable->get_subtable(6, 0); - REALM_ASSERT(subtable2->is_attached()); - size_t subrow = subtable2->add_empty_row(); - REALM_ASSERT(subtable2->is_attached()); - -#endif - if ((counter % 1000) == 0) { - // std::cerr << counter << "\n"; - } - } - } -} - -#endif // JAVA_MANY_COLUMNS_CRASH - TEST(Table_Null) { { diff --git a/test/unit-tests-ios/Base.lproj/LaunchScreen.xib b/test/unit-tests-ios/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 1ee396d9ed7..00000000000 --- a/test/unit-tests-ios/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/unit-tests-ios/Base.lproj/Main.storyboard b/test/unit-tests-ios/Base.lproj/Main.storyboard deleted file mode 100644 index f56d2f3bb56..00000000000 --- a/test/unit-tests-ios/Base.lproj/Main.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/unit-tests-ios/Images.xcassets/AppIcon.appiconset/Contents.json b/test/unit-tests-ios/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 1d060ed2882..00000000000 --- a/test/unit-tests-ios/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/test/unit-tests-ios/Info.plist b/test/unit-tests-ios/Info.plist deleted file mode 100644 index 40c6215d906..00000000000 --- a/test/unit-tests-ios/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/test/unit-tests-ios/ViewController.h b/test/unit-tests-ios/ViewController.h deleted file mode 100644 index 768ff025b4b..00000000000 --- a/test/unit-tests-ios/ViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -/************************************************************************* - * - * Copyright 2016 Realm Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - **************************************************************************/ - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/test/unit-tests-ios/ViewController.mm b/test/unit-tests-ios/ViewController.mm deleted file mode 100644 index 81f35751611..00000000000 --- a/test/unit-tests-ios/ViewController.mm +++ /dev/null @@ -1,25 +0,0 @@ -#import "ViewController.h" - -#include "test_path.hpp" -#include "test_all.hpp" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - std::string tmp_dir{[NSTemporaryDirectory() UTF8String]}; - realm::test_util::set_test_path_prefix(tmp_dir); - - std::string resource_path{[[[NSBundle mainBundle] resourcePath] UTF8String]}; - realm::test_util::set_test_resource_path(resource_path + "/"); - - test_all(0, nullptr); - exit(0); -} - -@end diff --git a/test/unit-tests-ios/main.m b/test/unit-tests-ios/main.m deleted file mode 100644 index b53eb7db03d..00000000000 --- a/test/unit-tests-ios/main.m +++ /dev/null @@ -1,13 +0,0 @@ -#import - -@interface AppDelegate : UIResponder -@property (strong, nonatomic) UIWindow *window; -@end -@implementation AppDelegate -@end - -int main(int argc, char * argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -}