aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-29 17:03:00 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-29 17:03:00 -0700
commit7a5a277c294f733feb60e84e6132940467edb374 (patch)
tree9e7f4e6c00f0cda198fc3c089c3f3c90228692da /fish_tests.cpp
parent38da76804e8e1c0e97ba4f59711b64f0637ced50 (diff)
Implement universal variable deletion. Adopt shared memory uvar notification.
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r--fish_tests.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp
index 4ab9ff19..eed6abd3 100644
--- a/fish_tests.cpp
+++ b/fish_tests.cpp
@@ -2161,10 +2161,11 @@ static void test_input()
}
#define UVARS_PER_THREAD 8
+#define UVARS_TEST_PATH L"/tmp/fish_uvars_test/varsfile.txt"
static int test_universal_helper(int *x)
{
- env_universal_t uvars(L"/tmp/fish_uvars_test/varsfile.txt");
+ env_universal_t uvars(UVARS_TEST_PATH);
for (int j=0; j < UVARS_PER_THREAD; j++)
{
const wcstring key = format_string(L"key_%d_%d", *x, j);
@@ -2176,8 +2177,17 @@ static int test_universal_helper(int *x)
err(L"Failed to sync universal variables");
}
fputc('.', stderr);
- fflush(stderr);
}
+
+ /* Last step is to delete the first key */
+ uvars.remove(format_string(L"key_%d_%d", *x, 0));
+ bool synced = uvars.sync(NULL);
+ if (! synced)
+ {
+ err(L"Failed to sync universal variables");
+ }
+ fputc('.', stderr);
+
return 0;
}
@@ -2193,7 +2203,7 @@ static void test_universal()
}
iothread_drain_all();
- env_universal_t uvars(L"/tmp/fish_uvars_test/varsfile.txt");
+ env_universal_t uvars(UVARS_TEST_PATH);
bool loaded = uvars.load();
if (! loaded)
{
@@ -2204,22 +2214,35 @@ static void test_universal()
for (int j=0; j < UVARS_PER_THREAD; j++)
{
const wcstring key = format_string(L"key_%d_%d", i, j);
- const wcstring val = format_string(L"val_%d_%d", i, j);
+ env_var_t expected_val;
+ if (j == 0)
+ {
+ expected_val = env_var_t::missing_var();
+ }
+ else
+ {
+ expected_val = format_string(L"val_%d_%d", i, j);
+ }
const env_var_t var = uvars.get(key);
- if (var != val)
+ if (j == 0)
+ {
+ assert(expected_val.missing());
+ }
+ if (var != expected_val)
{
- err(L"Wrong value for key %ls: %ls vs %ls\n", key.c_str(), val.c_str(), var.missing() ? L"<missing>" : var.c_str());
+ const wchar_t *missing_desc = L"<missing>";
+ err(L"Wrong value for key %ls: expected %ls, got %ls\n", key.c_str(), (expected_val.missing() ? missing_desc : expected_val.c_str()), (var.missing() ? missing_desc : var.c_str()));
}
}
}
- system("rm -Rf /tmp/fish_uvars_test");
+ if (system("rm -Rf /tmp/fish_uvars_test")) err(L"rrm failed");
putc('\n', stderr);
}
static void test_notifiers_with_strategy(universal_notifier_t::notifier_strategy_t strategy)
{
- say(L"Testing universal notifiers with strategy", (int)strategy);
+ say(L"Testing universal notifiers with strategy %d", (int)strategy);
universal_notifier_t *notifiers[16];
size_t notifier_count = sizeof notifiers / sizeof *notifiers;