Fix stamp file creation for zap unit test. (#27296)

unittest.main by default calls sys.exit so we did not get a chance
to create the stamp file.

Fix this and handle sys exit logic separately.

Co-authored-by: Andrei Litvin <andreilitvin@google.com>
diff --git a/scripts/tools/zap/test_generate.py b/scripts/tools/zap/test_generate.py
index ff7ea2c..d0ada5c 100755
--- a/scripts/tools/zap/test_generate.py
+++ b/scripts/tools/zap/test_generate.py
@@ -197,7 +197,9 @@
 
     PROGRAM_ARGUMENTS = process_args
 
-    unittest.main(argv=unittest_args)
+    test_results = unittest.main(argv=unittest_args, exit=False)
+    if test_results.result.failures:
+        sys.exit(1)
 
     if process_args.stamp_file:
         open(process_args.stamp_file, "wb").close()