Implement store error IO class, optional config validation, and ops init helper

This commit is contained in:
Carl Niklas Rydberg 2025-12-21 23:29:24 +01:00
parent a992e89766
commit 9754582ae7
5 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1 @@
---

View file

@ -0,0 +1,3 @@
Start testing: Dec 21 23:21 CET
----------------------------------------------------------
End testing: Dec 21 23:21 CET

View file

@ -37,6 +37,15 @@ typedef struct {
amduat_asl_store_config_t config); amduat_asl_store_config_t config);
} amduat_asl_store_ops_t; } amduat_asl_store_ops_t;
static inline void amduat_asl_store_ops_init(amduat_asl_store_ops_t *ops) {
if (ops == NULL) {
return;
}
ops->put = NULL;
ops->get = NULL;
ops->validate_config = NULL;
}
typedef struct { typedef struct {
amduat_asl_store_config_t config; amduat_asl_store_config_t config;
amduat_asl_store_ops_t ops; amduat_asl_store_ops_t ops;

View file

@ -693,7 +693,7 @@ bool amduat_asl_store_fs_init(amduat_asl_store_fs_t *fs,
amduat_asl_store_ops_t amduat_asl_store_fs_ops(void) { amduat_asl_store_ops_t amduat_asl_store_fs_ops(void) {
amduat_asl_store_ops_t ops; amduat_asl_store_ops_t ops;
memset(&ops, 0, sizeof(ops)); amduat_asl_store_ops_init(&ops);
ops.put = amduat_asl_store_fs_put_impl; ops.put = amduat_asl_store_fs_put_impl;
ops.get = amduat_asl_store_fs_get_impl; ops.get = amduat_asl_store_fs_get_impl;
ops.validate_config = amduat_asl_store_fs_validate_config; ops.validate_config = amduat_asl_store_fs_validate_config;

View file

@ -363,6 +363,7 @@ static int test_surf_success(void) {
cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256; cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256;
stub_store_init(&stub); stub_store_init(&stub);
stub.config = cfg; stub.config = cfg;
amduat_asl_store_ops_init(&ops);
ops.put = stub_store_put; ops.put = stub_store_put;
ops.get = stub_store_get; ops.get = stub_store_get;
amduat_asl_store_init(&store, cfg, ops, &stub); amduat_asl_store_init(&store, cfg, ops, &stub);
@ -488,6 +489,7 @@ static int test_surf_missing_program(void) {
cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256; cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256;
stub_store_init(&stub); stub_store_init(&stub);
stub.config = cfg; stub.config = cfg;
amduat_asl_store_ops_init(&ops);
ops.put = stub_store_put; ops.put = stub_store_put;
ops.get = stub_store_get; ops.get = stub_store_get;
amduat_asl_store_init(&store, cfg, ops, &stub); amduat_asl_store_init(&store, cfg, ops, &stub);
@ -566,6 +568,7 @@ static int test_surf_missing_input(void) {
cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256; cfg.hash_id = AMDUAT_HASH_ASL1_ID_SHA256;
stub_store_init(&stub); stub_store_init(&stub);
stub.config = cfg; stub.config = cfg;
amduat_asl_store_ops_init(&ops);
ops.put = stub_store_put; ops.put = stub_store_put;
ops.get = stub_store_get; ops.get = stub_store_get;
amduat_asl_store_init(&store, cfg, ops, &stub); amduat_asl_store_init(&store, cfg, ops, &stub);