From b42a22fce832b5422de33037f884802526b69187 Mon Sep 17 00:00:00 2001
From: Utz-Uwe Haus <uhaus@cray.com>
Date: Fri, 24 Apr 2020 09:59:32 +0200
Subject: [PATCH] work on declaration_seal test

---
 attributes/maestro-schema.c    | 28 ++++++++++++++++------------
 tests/check_declaration_seal.c |  2 +-
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/attributes/maestro-schema.c b/attributes/maestro-schema.c
index 1dcda1d7..b9d6138d 100644
--- a/attributes/maestro-schema.c
+++ b/attributes/maestro-schema.c
@@ -1789,6 +1789,18 @@ mstro_attribute_dict__insert_default(mstro_attribute_dict dict,
   struct mstro_attribute_entry_ *entry=NULL;
   bool must_insert=false;
   mstro_status status = MSTRO_OK;
+
+  mstro_schema_attribute attr=NULL;
+  status = mstro_schema_lookup_attribute(dict->schema, mstro_symbol_name(key), &attr);
+  if(status!=MSTRO_OK) {
+    ERR("Cannot find attribute in schema !? (should not happen here)\n");
+    goto BAILOUT;
+  }
+  mstro_schema_type tdecl;
+  status = mstro_schema_lookup_type(dict->schema, attr->typespec, &tdecl);
+  if(status!=MSTRO_OK) {
+    goto BAILOUT;
+  }
   
   HASH_FIND(hh, dict->dict, &key, sizeof(mstro_symbol), entry);
   if(!entry) {
@@ -1797,25 +1809,17 @@ mstro_attribute_dict__insert_default(mstro_attribute_dict dict,
       ERR("Cannot allocate default entry\n");
       goto BAILOUT;
     }
-    must_insert=true;
+    entry->kind=tdecl->parsed_type->kind;
+    
     status = mstro_attribute_entry__set_size(entry, entry->kind);
     if(status!=MSTRO_OK) {
+      ERR("Cannot set entry size\n");
       goto BAILOUT;
     }
     entry->val = NULL;
+    must_insert=true;
   } 
     
-  mstro_schema_attribute attr=NULL;
-  status = mstro_schema_lookup_attribute(dict->schema, mstro_symbol_name(key), &attr);
-  if(status!=MSTRO_OK) {
-    ERR("Cannot find attribute in schema !? (should not happen here)\n");
-    goto BAILOUT;
-  }
-  mstro_schema_type tdecl;
-  status = mstro_schema_lookup_type(dict->schema, attr->typespec, &tdecl);
-  if(status!=MSTRO_OK) {
-    goto BAILOUT;
-  }
   assert(entry->kind = tdecl->parsed_type->kind);
   
   /* duplicate; if user-supplied: allocate freshly */
diff --git a/tests/check_declaration_seal.c b/tests/check_declaration_seal.c
index 117e5f19..a894559b 100644
--- a/tests/check_declaration_seal.c
+++ b/tests/check_declaration_seal.c
@@ -56,7 +56,7 @@ CHEAT_TEST(cdo_declaration_seal_works,
 
            cheat_assert(MSTRO_OK
                         == mstro_cdo_attribute_get(
-                            cdo, "allocate_now", &type, &val));
+                            cdo, "allocate-now", &type, &val));
            fprintf(stdout, "check: default allocate_now: %d (%p)\n",
                    *(const int*)val, val);
 
-- 
GitLab