mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Reformat plugin.storage btest to be more consistent with other storage tests
This commit is contained in:
parent
656e88eaa8
commit
046f32a6df
2 changed files with 41 additions and 24 deletions
|
@ -1,5 +1,14 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
open result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
open result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||||
|
put result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
get result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value5678]
|
||||||
|
get result same as inserted, T
|
||||||
|
|
||||||
|
erase result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
get result after erase, [code=Storage::KEY_NOT_FOUND, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
|
||||||
|
close result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
results of trying to use closed handle: get: Storage::NOT_CONNECTED, put: Storage::NOT_CONNECTED, erase: Storage::NOT_CONNECTED
|
results of trying to use closed handle: get: Storage::NOT_CONNECTED, put: Storage::NOT_CONNECTED, erase: Storage::NOT_CONNECTED
|
||||||
|
|
||||||
open result 2, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGEDUMMY: open_fail was set to true, returning error, value=<opaque of BackendHandleVal>]
|
open result 2, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGEDUMMY: open_fail was set to true, returning error, value=<opaque of BackendHandleVal>]
|
||||||
close result of closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
close result on closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
||||||
|
|
|
@ -25,36 +25,44 @@ event zeek_init() {
|
||||||
local key = "key1234";
|
local key = "key1234";
|
||||||
local value = "value5678";
|
local value = "value5678";
|
||||||
|
|
||||||
# Test basic operation. The second get() should return an error
|
# Basic operation. Open, put, and get the value back.
|
||||||
# as the key should have been erased.
|
local res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
||||||
local open_res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
print "open result", res;
|
||||||
print "open result", open_res;
|
local b = res$value;
|
||||||
local b = open_res$value;
|
|
||||||
local put_res = Storage::Sync::put(b, [$key=key, $value=value, $overwrite=F]);
|
|
||||||
local get_res = Storage::Sync::get(b, key);
|
|
||||||
if ( get_res$code != Storage::SUCCESS ) {
|
|
||||||
print("Got an invalid value in response!");
|
|
||||||
}
|
|
||||||
|
|
||||||
local erase_res = Storage::Sync::erase(b, key);
|
res = Storage::Sync::put(b, [$key=key, $value=value, $overwrite=F]);
|
||||||
get_res = Storage::Sync::get(b, key);
|
print "put result", res;
|
||||||
Storage::Sync::close_backend(b);
|
|
||||||
|
|
||||||
if ( get_res$code != Storage::SUCCESS && get_res?$error_str )
|
res = Storage::Sync::get(b, key);
|
||||||
Reporter::error(get_res$error_str);
|
print "get result", res;
|
||||||
|
if ( res$code == Storage::SUCCESS && res?$value )
|
||||||
|
print "get result same as inserted", value == (res$value as string);
|
||||||
|
print "";
|
||||||
|
|
||||||
|
# Erase the key and attempt to get it back.
|
||||||
|
res = Storage::Sync::erase(b, key);
|
||||||
|
print "erase result", res;
|
||||||
|
res = Storage::Sync::get(b, key);
|
||||||
|
print "get result after erase", res;
|
||||||
|
print "";
|
||||||
|
|
||||||
|
# Close the handle and test trying to use the closed handle.
|
||||||
|
res = Storage::Sync::close_backend(b);
|
||||||
|
print "close result", res;
|
||||||
|
|
||||||
# Test attempting to use the closed handle.
|
# Test attempting to use the closed handle.
|
||||||
put_res = Storage::Sync::put(b, [$key="a", $value="b", $overwrite=F]);
|
local put_res = Storage::Sync::put(b, [$key="a", $value="b", $overwrite=F]);
|
||||||
get_res = Storage::Sync::get(b, "a");
|
local get_res = Storage::Sync::get(b, "a");
|
||||||
erase_res = Storage::Sync::erase(b, "a");
|
local erase_res = Storage::Sync::erase(b, "a");
|
||||||
|
|
||||||
print(fmt("results of trying to use closed handle: get: %s, put: %s, erase: %s",
|
print(fmt("results of trying to use closed handle: get: %s, put: %s, erase: %s",
|
||||||
get_res$code, put_res$code, erase_res$code));
|
get_res$code, put_res$code, erase_res$code));
|
||||||
|
print "";
|
||||||
|
|
||||||
# Test failing to open the handle and test closing an invalid handle.
|
# Test failing to open the handle and test closing an invalid handle.
|
||||||
opts$dummy$open_fail = T;
|
opts$dummy = [$open_fail = T];
|
||||||
open_res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
||||||
print "open result 2", open_res;
|
print "open result 2", res;
|
||||||
local close_res = Storage::Sync::close_backend(open_res$value);
|
res = Storage::Sync::close_backend(res$value);
|
||||||
print "close result of closed handle", close_res;
|
print "close result on closed handle", res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue