OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-rocks commits / 975d864

Unit tests: revise counts for the new key
Fix a log of off-by-one counts in these unit tests. The counts changed because of teh (Predicate "*-IsKeyFlag-*") gets added to the atomspace
975d86493ef065dbecfc94a7d52205d89e2a2483
by Linas Vepstas <linasvepstas@gmail.com> · 2025-12-09T01:57:39.000Z

Changed files (8) +70 -47

tests/persist/monospace/MonoBasicSaveUTest.cxxtest +3 -2
……@@ -409,8 +409,9 @@ void MonoBasicSaveUTest::test_table()
409409 size_t num_fetched = table2->get_size();
410410 printf("test_table: Done loading table; fetched %lu, expected %lu\n",
411411 num_fetched, num_stored);
412 // One extra, for the (PredicateNode "*-TruthValueKey-*")
413 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+1);
412 // Two extra, for (PredicateNode "*-TruthValueKey-*")
413 // and (PredicateNode "*-IsKeyFlag-*")
414 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+2);
414415
415416 idx = 0;
416417 check_table(idx++, table2, "aaa ");
tests/persist/monospace/MonoDeleteUTest.cxxtest +15 -8
……@@ -448,6 +448,7 @@ void DeleteUTest::test_remove(void)
448448 /* Push all atoms out to storage */
449449 store->store_atomspace();
450450
451 // *-IsKeyFlag-* is not added until after store_atomspace
451452 printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+1);
452453 TSM_ASSERT("Initial unexpected atomspace size",
453454 ((unsigned)(7*idx+1)) == _as->get_size());
……@@ -460,6 +461,7 @@ void DeleteUTest::test_remove(void)
460461 for (i=0; i<idx; i++)
461462 extract_links(i, _as);
462463
464 // *-IsKeyFlag-* is not added until after fetch
463465 printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+1);
464466 TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+1)) == _as->get_size());
465467
……@@ -473,9 +475,10 @@ void DeleteUTest::test_remove(void)
473475 for (i=0; i<idx; i++)
474476 delete_links(i, store);
475477
476 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+2);
478 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
479 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3);
477480 TSM_ASSERT("Post-remove unexpected atomspace size",
478 ((unsigned)(4*idx+2)) == _as->get_size());
481 ((unsigned)(4*idx+3)) == _as->get_size());
479482
480483 /* Verify that the atoms are really gone from storage. */
481484 for (i=0; i<idx; i++) {
……@@ -483,9 +486,10 @@ void DeleteUTest::test_remove(void)
483486 check_remove(i, _as, "verify-gone");
484487 }
485488
486 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+2);
489 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
490 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3);
487491 TSM_ASSERT("Post-refetch unexpected atomspace size",
488 ((unsigned)(7*idx+2)) == _as->get_size());
492 ((unsigned)(7*idx+3)) == _as->get_size());
489493
490494 /* Kill data for good */
491495 _as->clear();
……@@ -540,6 +544,7 @@ void DeleteUTest::test_recurse(void)
540544 for (i=0; i<zap; i++)
541545 extract_nodes(i, _as);
542546
547 // *-IsKeyFlag-* is not added until after fetch
543548 size_t expsz = 7*(idx-zap) + 3*zap + 1;
544549 printf("Atomspace size=%lu expect=%lu\n",
545550 _as->get_size(), expsz);
……@@ -555,9 +560,10 @@ void DeleteUTest::test_recurse(void)
555560 for (i=0; i<zap; i++)
556561 delete_nodes(i, store);
557562
563 // +1 for *-TruthValueKey-*, +1 for *-IsKeyFlag-* (added after fetch)
558564 printf("Post-remove size=%lu expect=%lu\n",
559 _as->get_size(), expsz+1);
560 TSM_ASSERT("Unexpected atomspace size", expsz+1 == _as->get_size());
565 _as->get_size(), expsz+2);
566 TSM_ASSERT("Unexpected atomspace size", expsz+2 == _as->get_size());
561567
562568 store->barrier();
563569
……@@ -566,10 +572,11 @@ void DeleteUTest::test_recurse(void)
566572 fetch_space(i, store);
567573 }
568574
575 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
569576 printf("Post-refetch size=%lu expect=%d\n",
570 _as->get_size(), 7*idx+2);
577 _as->get_size(), 7*idx+3);
571578 TSM_ASSERT("Unexpected atomspace size",
572 ((unsigned) 7*idx+2) == _as->get_size());
579 ((unsigned) 7*idx+3) == _as->get_size());
573580
574581 /* Check that the removed atoms really got zapped. */
575582 for (i=0; i<zap; i++) {
tests/persist/monospace/MonoValueSaveUTest.cxxtest +13 -9
……@@ -348,11 +348,12 @@ void ValueSaveUTest::test_load_by_type()
348348 store->fetch_all_atoms_of_type(CONCEPT_NODE);
349349 store->barrier();
350350
351 // Six: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*"
352 // and PredicateNode "some pred key" -- the two preds show up
353 // when the attached values are fetched.
351 // Eight: 4 ConceptNodes, PredicateNode "*-TruthValueKey-*",
352 // PredicateNode "*-IsKeyFlag-*", PredicateNode "some pred key",
353 // and the MonoStorageNode -- the preds show up when the
354 // attached values are fetched.
354355 printf ("fetched %lu atoms\n", as->get_size());
355 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 7);
356 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 8);
356357
357358 Handle gkey = as->add_node(PREDICATE_NODE, "some pred key");
358359 Handle gaf = as->add_node(CONCEPT_NODE, "float node");
……@@ -512,8 +513,9 @@ void ValueSaveUTest::test_link_by_type()
512513 // only the values on the C-links should be fetched.
513514 store->fetch_all_atoms_of_type(LIST_LINK);
514515 store->barrier();
516 // +1 for *-IsKeyFlag-*
515517 printf ("fetched %lu atoms\n", as->get_size());
516 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
518 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
517519
518520 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
519521 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -722,9 +724,10 @@ void ValueSaveUTest::test_link_by_type_quoted()
722724 store->fetch_all_atoms_of_type(LIST_LINK);
723725 store->barrier();
724726
725 // We created 9 new atoms above, so expect 15 from before plus 9
726 printf ("fetched %lu atoms, expecting 24\n", as->get_size());
727 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 24);
727 // We created 9 new atoms above, so expect 16 from before plus 9
728 // +1 for *-IsKeyFlag-*
729 printf ("fetched %lu atoms, expecting 25\n", as->get_size());
730 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25);
728731
729732 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
730733 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -936,8 +939,9 @@ void ValueSaveUTest::test_incoming()
936939 store->fetch_incoming_set(gal, false);
937940 store->fetch_incoming_set(gav, false);
938941 store->barrier();
942 // +1 for *-IsKeyFlag-*
939943 printf ("fetched %lu atoms\n", as->get_size());
940 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
944 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
941945
942946 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
943947 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
tests/persist/rocks/BasicSaveUTest.cxxtest +3 -2
……@@ -426,8 +426,9 @@ void BasicSaveUTest::test_table()
426426 size_t num_fetched = table2->get_size();
427427 printf("test_table: Done loading table; fetched %lu, expected %lu\n",
428428 num_fetched, num_stored);
429 // One extra, for the (PredicateNode "*-TruthValueKey-*")
430 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+1);
429 // Two extra, for (PredicateNode "*-TruthValueKey-*")
430 // and (PredicateNode "*-IsKeyFlag-*")
431 TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+2);
431432
432433 idx = 0;
433434 check_table(idx++, table2, "aaa ");
tests/persist/rocks/DeleteUTest.cxxtest +12 -8
……@@ -472,9 +472,10 @@ void DeleteUTest::test_remove(void)
472472 for (i=0; i<idx; i++)
473473 delete_links(i, store);
474474
475 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+2);
475 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
476 printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3);
476477 TSM_ASSERT("Post-remove unexpected atomspace size",
477 ((unsigned)(4*idx+2)) == _as->get_size());
478 ((unsigned)(4*idx+3)) == _as->get_size());
478479
479480 /* Verify that the atoms are really gone from storage. */
480481 for (i=0; i<idx; i++) {
……@@ -482,9 +483,10 @@ void DeleteUTest::test_remove(void)
482483 check_remove(i, _as, "verify-gone");
483484 }
484485
485 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+2);
486 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
487 printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3);
486488 TSM_ASSERT("Post-refetch unexpected atomspace size",
487 ((unsigned)(7*idx+2)) == _as->get_size());
489 ((unsigned)(7*idx+3)) == _as->get_size());
488490
489491 /* Kill data for good */
490492 _as->clear();
……@@ -554,9 +556,10 @@ void DeleteUTest::test_recurse(void)
554556 for (i=0; i<zap; i++)
555557 delete_nodes(i, store);
556558
559 // +1 for *-IsKeyFlag-*
557560 printf("Post-remove size=%lu expect=%lu\n",
558 _as->get_size(), expsz+1);
559 TSM_ASSERT("Unexpected atomspace size", expsz+1 == _as->get_size());
561 _as->get_size(), expsz+2);
562 TSM_ASSERT("Unexpected atomspace size", expsz+2 == _as->get_size());
560563
561564 store->barrier();
562565
……@@ -565,10 +568,11 @@ void DeleteUTest::test_recurse(void)
565568 fetch_space(i, store);
566569 }
567570
571 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
568572 printf("Post-refetch size=%lu expect=%d\n",
569 _as->get_size(), 7*idx+2);
573 _as->get_size(), 7*idx+3);
570574 TSM_ASSERT("Unexpected atomspace size",
571 ((unsigned) 7*idx+2) == _as->get_size());
575 ((unsigned) 7*idx+3) == _as->get_size());
572576
573577 /* Check that the removed atoms really got zapped. */
574578 for (i=0; i<zap; i++) {
tests/persist/rocks/MultiDeleteUTest.cxxtest +6 -5
……@@ -173,6 +173,7 @@ void MultiDeleteUTest::test_add_delete(void)
173173 // Verify the local AtomSpace size. Should be 34:
174174 // The StorageNode itself, the (Concept "aaaa") and
175175 // 16 Concept and Lists from thread-id modulo 16
176 // Note: *-IsKeyFlag-* is NOT added by store_atom, only by load operations
176177 TS_ASSERT_EQUALS(as->get_size(), 2 + 2*(n_threads+6));
177178
178179 // Verify the DB contents: pull everything from the DB,
……@@ -195,13 +196,13 @@ void MultiDeleteUTest::test_add_delete(void)
195196 store->load_atomspace();
196197 printf("Final AtomSpace size=%lu\n", as->get_size());
197198
198 // Size should be 19: the 18 from before plus that annoying
199 // (Predicate "*-TruthValueKey-*")
199 // Size should be 20: the 18 from before plus
200 // (Predicate "*-TruthValueKey-*") and (Predicate "*-IsKeyFlag-*")
200201 // Well, actually, there is no guarantee that the removes will
201202 // happen after the stores. Best we can do is check lower and
202 // upper bounds of 18 and 34:
203 size_t min_size = 3 + n_threads + 6;
204 size_t max_size = 3 + 2*(n_threads + 6);
203 // upper bounds of 20 and 36:
204 size_t min_size = 4 + n_threads + 6;
205 size_t max_size = 4 + 2*(n_threads + 6);
205206 if (as->get_size() < min_size or max_size < as->get_size())
206207 printf("Error: Bad size! AtomSpace contents =\n%s\n",
207208 as->to_string().c_str());
tests/persist/rocks/ValueSaveUTest.cxxtest +12 -9
……@@ -348,11 +348,11 @@ void ValueSaveUTest::test_load_by_type()
348348 store->fetch_all_atoms_of_type(CONCEPT_NODE);
349349 store->barrier();
350350
351 // Six: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*"
352 // and PredicateNode "some pred key" -- the two preds show up
353 // when the attached values are fetched.
351 // Eight: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*",
352 // PredicateNode "*-IsKeyFlag-*", PredicateNode "some pred key",
353 // and the RocksStorageNode.
354354 printf ("fetched %lu atoms\n", as->get_size());
355 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 7);
355 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 8);
356356
357357 Handle gkey = as->add_node(PREDICATE_NODE, "some pred key");
358358 Handle gaf = as->add_node(CONCEPT_NODE, "float node");
……@@ -510,10 +510,11 @@ void ValueSaveUTest::test_link_by_type()
510510 // The B-nodes are added after the fetch. In either case,
511511 // there should not be any values fetched for either A or B;
512512 // only the values on the C-links should be fetched.
513 // +1 for *-IsKeyFlag-*
513514 store->fetch_all_atoms_of_type(LIST_LINK);
514515 store->barrier();
515516 printf ("fetched %lu atoms\n", as->get_size());
516 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
517 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
517518
518519 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
519520 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -722,9 +723,10 @@ void ValueSaveUTest::test_link_by_type_quoted()
722723 store->fetch_all_atoms_of_type(LIST_LINK);
723724 store->barrier();
724725
725 // We created 9 new atoms above, so expect 15 from before plus 9
726 printf ("fetched %lu atoms, expecting 24\n", as->get_size());
727 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 24);
726 // We created 9 new atoms above, so expect 16 from before plus 9
727 // +1 for *-IsKeyFlag-*
728 printf ("fetched %lu atoms, expecting 25\n", as->get_size());
729 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25);
728730
729731 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
730732 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
……@@ -936,8 +938,9 @@ void ValueSaveUTest::test_incoming()
936938 store->fetch_incoming_set(gal, false);
937939 store->fetch_incoming_set(gav, false);
938940 store->barrier();
941 // +1 for *-IsKeyFlag-*
939942 printf ("fetched %lu atoms\n", as->get_size());
940 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 15);
943 TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16);
941944
942945 Handle gbf = as->add_node(CONCEPT_NODE, "b float node");
943946 Handle gbt = as->add_node(CONCEPT_NODE, "b string node");
tests/persist/rocks/space-episodic-test.scm +6 -4
……@@ -59,8 +59,8 @@
5959 (count-all (cog-value (ConceptNode "foo") (Predicate "real life")))
6060 (count-all (cog-value (ConceptNode "foo") (Predicate "repressed mem"))))
6161
62; Verify contents
63(test-assert "base-count" (equal? 12 (count-all)))
62; Verify contents (+1 for *-IsKeyFlag-*)
63(test-assert "base-count" (equal? 13 (count-all)))
6464(test-assert "space1-count" (equal? 8
6565 (count-all (cog-value (ConceptNode "foo") (Predicate "real life")))))
6666(test-assert "space2-count" (equal? 6
……@@ -102,8 +102,9 @@
102102; Plus two more: (Predicate "*-store-atomspace-*")
103103; and (Predicate "*-load-atomspace-*") and *-open-* and *-close-*
104104; and (Predicate "kayfabe") from test-utils.
105; +1 for (Predicate "*-IsKeyFlag-*")
105106
106(test-assert "base-count" (equal? 17 (count-all)))
107(test-assert "base-count" (equal? 18 (count-all)))
107108(test-assert "space1-count" (equal? 0
108109 (count-all (cog-value (ConceptNode "foo") (Predicate "real life")))))
109110(test-assert "space2-count" (equal? 0
……@@ -114,7 +115,8 @@
114115(load-atomspace (AtomSpace "crushing defeat"))
115116(cog-close gsn)
116117
117(test-assert "base-count" (equal? 18 (count-all)))
118; +1 for (Predicate "*-IsKeyFlag-*")
119(test-assert "base-count" (equal? 19 (count-all)))
118120(test-assert "space1-count" (equal? 8
119121 (count-all (cog-value (ConceptNode "foo") (Predicate "real life")))))
120122(test-assert "space2-count" (equal? 6