Skip to content

Commit

Permalink
Add unit test for AtomSpace crash.
Browse files Browse the repository at this point in the history
The crash was reported in
#20

The fix is in
opencog/atomspace#3037
  • Loading branch information
linas committed May 11, 2023
1 parent 168379c commit 4499f34
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/persist/rocks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ADD_GUILE_TEST(FrameDelete frame-delete-test.scm)
ADD_GUILE_TEST(FrameProgressive frame-progressive-test.scm)
ADD_GUILE_TEST(FrameLinks frame-links-test.scm)
ADD_GUILE_TEST(FrameValues frame-values-test.scm)
ADD_GUILE_TEST(FramePrint frame-print-test.scm)
ADD_GUILE_TEST(Promote promote-test.scm)
#
ADD_CXXTEST(LargeFlatUTest)
Expand Down
52 changes: 52 additions & 0 deletions tests/persist/rocks/frame-print-test.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
;
; frame-print-test.scm
; Test for crash (null-pointer deref) for a simple usercase.
;
; The crash was in AtomSpace code.
; See https://github.com/opencog/atomspace-rocks/issues/20
; for details.
; The fix is in https://github.com/opencog/atomspace/pull/3037
;
(use-modules (srfi srfi-1))
(use-modules (opencog) (opencog test-runner))
(use-modules (opencog persist) (opencog persist-rocks))

(include "test-utils.scm")
(whack "/tmp/cog-rocks-unit-test")

(opencog-test-runner)

; -------------------------------------------------------------------
; Test that load of a series of nested links is done correctly.

(define (test-print)

(define a (AtomSpace))
(define b (AtomSpace))
(define c (AtomSpace a b))

(cog-set-atomspace! a)
(Concept "I'm in A")
(cog-prt-atomspace)

(cog-set-atomspace! b)
(Concept "I'm in B")
(cog-prt-atomspace)

(cog-set-atomspace! c)
(define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-unit-test"))
(cog-open rsn)
(store-atomspace)
(cog-prt-atomspace)

(cog-close rsn)
)

(define test-name "test print")
(test-begin test-name)
(test-print)
(test-end test-name)

; ===================================================================
(whack "/tmp/cog-rocks-unit-test")
(opencog-test-end)

0 comments on commit 4499f34

Please sign in to comment.