fortrangoingonforty/fortsh / 0c7311f

Browse files

Fix memory pool test failures (27/27 pass)

Authored by espadonne
SHA
0c7311f3ff9570657cb3ee5b70ec2c1edd1c4a96
Parents
e372ba6
Tree
c7b9e80

3 changed files

StatusFile+-
M Makefile 10 6
M src/common/memory_dashboard.f90 6 0
M tests/memory_pool_test_bench.sh 5 5
Makefilemodified
@@ -31,7 +31,12 @@ ifeq ($(NO_MEMPOOL),1)
3131
     $(info Memory pooling DISABLED - using standard allocation)
3232
 else
3333
     POOL_FLAGS = -DUSE_MEMORY_POOL
34
-    $(info Memory pooling ENABLED - using zero-copy string pool [DEFAULT])
34
+    ifeq ($(MEMPOOL_DEBUG),1)
35
+        POOL_FLAGS += -DMEMPOOL_DEBUG
36
+        $(info Memory pooling ENABLED with DEBUG output - using zero-copy string pool)
37
+    else
38
+        $(info Memory pooling ENABLED - using zero-copy string pool [DEFAULT])
39
+    endif
3540
 endif
3641
 
3742
 # C compiler for string operations library
@@ -97,11 +102,9 @@ else
97102
     POOL_OBJECTS = $(BUILDDIR)/common/string_pool.o $(BUILDDIR)/common/memory_dashboard.o
98103
 endif
99104
 
100
-# Object files in dependency order
101
-# Note: Circular dependencies exist between parser/expansion/substitution/command_capture
102
-# The linker resolves these at link time, so build order matters
103
-# Force sequential build to handle circular dependencies correctly
104
-.NOTPARALLEL:
105
+# Object files with explicit dependencies
106
+# All module dependencies are properly declared in the rules below,
107
+# so parallel builds work correctly
105108
 OBJECTS = $(BUILDDIR)/common/types.o \
106109
           $(BUILDDIR)/common/error_handling.o \
107110
           $(BUILDDIR)/common/performance.o \
@@ -415,6 +418,7 @@ help:
415418
 	@echo "Memory pooling options:"
416419
 	@echo "  make          - Build with memory pooling (DEFAULT)"
417420
 	@echo "  NO_MEMPOOL=1 make - Build without memory pooling"
421
+	@echo "  MEMPOOL_DEBUG=1 make - Build with memory pool debug output"
418422
 	@echo ""
419423
 	@echo "C string library (flang-new workaround):"
420424
 	@echo "  c-strings     - Build C string library test"
src/common/memory_dashboard.f90modified
@@ -84,6 +84,12 @@ contains
8484
     dashboard%verbose = .false.
8585
     if (present(verbose)) dashboard%verbose = verbose
8686
 
87
+#ifdef MEMPOOL_DEBUG
88
+    ! Enable verbose output when MEMPOOL_DEBUG is defined
89
+    dashboard%verbose = .true.
90
+    write(output_unit, '(A)') "[MEMPOOL_DEBUG] Memory dashboard initialized in debug mode"
91
+#endif
92
+
8793
     ! Get start time (simplified - would use system clock in real implementation)
8894
     dashboard%session_start_time = 0
8995
 
tests/memory_pool_test_bench.shmodified
@@ -76,7 +76,7 @@ section "1. BUILD VALIDATION"
7676
 subsection "Building pooled version"
7777
 cd "$FORTSH_DIR" || exit 1
7878
 make clean > /dev/null 2>&1
79
-if MEMPOOL=1 make > /dev/null 2>&1; then
79
+if make > /dev/null 2>&1; then
8080
     pass "Pooled build successful"
8181
     cp bin/fortsh "$FORTSH_POOLED"
8282
 else
@@ -86,7 +86,7 @@ fi
8686
 
8787
 subsection "Building traditional version"
8888
 make clean > /dev/null 2>&1
89
-if make > /dev/null 2>&1; then
89
+if make NO_MEMPOOL=1 > /dev/null 2>&1; then
9090
     pass "Traditional build successful"
9191
     cp bin/fortsh "$FORTSH_TRADITIONAL"
9292
 else
@@ -266,15 +266,15 @@ else
266266
 fi
267267
 
268268
 subsection "Nested expansions"
269
-# Test deeply nested expansions
270
-TEST_CMD='A=1; B=A; C=B; D=C; E=D; eval eval eval eval echo \$\$\$\$$E'
269
+# Test deeply nested expansions with variable indirection (deterministic)
270
+TEST_CMD='V=world; X="\$V"; Y="\$X"; eval eval echo "$Y"'
271271
 POOLED_OUT=$("$FORTSH_POOLED" -c "$TEST_CMD" 2>&1)
272272
 TRAD_OUT=$("$FORTSH_TRADITIONAL" -c "$TEST_CMD" 2>&1)
273273
 
274274
 if [ "$POOLED_OUT" = "$TRAD_OUT" ]; then
275275
     pass "Stress: Nested expansions"
276276
 else
277
-    fail "Stress: Different nested expansion behavior"
277
+    fail "Stress: Different nested expansion behavior" "Pooled: '$POOLED_OUT', Traditional: '$TRAD_OUT'"
278278
 fi
279279
 
280280
 # =====================================