Browse Source

Refuse to reload session unless test id and version match

Alois Mahdal 6 years ago
parent
commit
edb9b72ff9
1 changed files with 14 additions and 0 deletions
  1. 14
    0
      src/jat.sh.skel

+ 14
- 0
src/jat.sh.skel View File

590
     # Load active session if found; otherwise initialize new one.
590
     # Load active session if found; otherwise initialize new one.
591
     #
591
     #
592
     local reload=false
592
     local reload=false
593
+    local old_test_id
594
+    local old_test_version
593
     mkdir -p "$JAT__DIR" \
595
     mkdir -p "$JAT__DIR" \
594
      || die "could not initialize JAT__DIR: $JAT__DIR"
596
      || die "could not initialize JAT__DIR: $JAT__DIR"
595
     __JAT__SDIR=$JAT__DIR/session
597
     __JAT__SDIR=$JAT__DIR/session
600
     export JAT__YLOG
602
     export JAT__YLOG
601
     debug -v reload __JAT__SDIR
603
     debug -v reload __JAT__SDIR
602
     if $reload; then
604
     if $reload; then
605
+        old_test_id=$(__jat__sd_keyr test_id)
606
+        old_test_version=$(__jat__sd_keyr test_version)
607
+        test "$old_test_id" == "$JAT__TEST_ID" || {
608
+            warn -v JAT__TEST_ID old_test_id
609
+            die "cannot reload session of different test"
610
+        }
611
+        test "$old_test_version" == "$JAT__TEST_VERSION" || {
612
+            warn -v JAT__TEST_VERSION old_test_version
613
+            die "cannot reload session of different test version"
614
+        }
603
         __jat__log_event SINFO "reloaded session" "" \
615
         __jat__log_event SINFO "reloaded session" "" \
604
             -- \
616
             -- \
605
             "JAT__LOG_FMT=$__JAT__LOG_FMT" \
617
             "JAT__LOG_FMT=$__JAT__LOG_FMT" \
617
             echo "start: $(__jat__newstamp)"
629
             echo "start: $(__jat__newstamp)"
618
             echo "events:"
630
             echo "events:"
619
         } | __jat__writelog
631
         } | __jat__writelog
632
+        __jat__sd_keyw test_id "$JAT__TEST_ID"
633
+        __jat__sd_keyw test_version "$JAT__TEST_VERSION"
620
         __jat__pdummy
634
         __jat__pdummy
621
         __jat__log_event SINFO "started new session"
635
         __jat__log_event SINFO "started new session"
622
         __jat__show_sinitn
636
         __jat__show_sinitn