Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Sep 2019 14:05:44 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352898 - head/tests/sys/kern
Message-ID:  <201909301405.x8UE5i3w049532@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Mon Sep 30 14:05:44 2019
New Revision: 352898
URL: https://svnweb.freebsd.org/changeset/base/352898

Log:
  Fix coredump_phnum_test when kern.compress_user_cores != 0
  
  If `kern.compress_user_cores` is non-zero, decompress the core file.
  
  Use `sysctl -f` to restore previous values.
  
  Don't bother restoring `ulimit -c`, since that's a per-process value.
  
  Check more commands with `atf_check`.
  
  Reviewed by:	olivier ngie
  MFC after:	1 week
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D21820

Modified:
  head/tests/sys/kern/coredump_phnum_test.sh

Modified: head/tests/sys/kern/coredump_phnum_test.sh
==============================================================================
--- head/tests/sys/kern/coredump_phnum_test.sh	Mon Sep 30 13:34:30 2019	(r352897)
+++ head/tests/sys/kern/coredump_phnum_test.sh	Mon Sep 30 14:05:44 2019	(r352898)
@@ -40,21 +40,31 @@ coredump_phnum_head()
 coredump_phnum_body()
 {
 	# Set up core dumping
-	cat > coredump_phnum_restore_state.sh <<-EOF
-	#!/bin/sh
-	ulimit -c '$(ulimit -c)'
-	sysctl kern.coredump=$(sysctl -n kern.coredump)
-	sysctl kern.corefile='$(sysctl -n kern.corefile)'
-	sysctl kern.compress_user_cores='$(sysctl -n kern.compress_user_cores)'
-EOF
+	atf_check -o save:coredump_phnum_restore_state sysctl -e \
+	    kern.coredump kern.corefile
 
 	ulimit -c unlimited
-	sysctl kern.coredump=1
-	sysctl kern.compress_user_cores=0
-	sysctl kern.corefile="$(pwd)/coredump_phnum_helper.core"
+	atf_check -o ignore sysctl kern.coredump=1
+	atf_check -o ignore sysctl kern.corefile=coredump_phnum_helper.core
+	atf_check -o save:cuc sysctl -n kern.compress_user_cores
+	read cuc < cuc
 
 	atf_check -s signal:sigabrt "$(atf_get_srcdir)/coredump_phnum_helper"
 
+	case "$cuc" in
+	0)
+		;;
+	1)
+		atf_check gunzip coredump_phnum_helper.core.gz
+		;;
+	2)
+		atf_check zstd -qd coredump_phnum_helper.core.zst
+		;;
+	*)
+		atf_skip "unsupported kern.compress_user_cores=$cuc"
+		;;
+	esac
+
 	# Check that core looks good
 	if [ ! -f coredump_phnum_helper.core ]; then
 		atf_fail "Helper program did not dump core"
@@ -76,10 +86,11 @@ EOF
 coredump_phnum_cleanup()
 {
 	rm -f coredump_phnum_helper.core
-	if [ -f coredump_phnum_restore_state.sh ]; then
-		. ./coredump_phnum_restore_state.sh
+	if [ -f coredump_phnum_restore_state ]; then
+		sysctl -f coredump_phnum_restore_state
+		rm -f coredump_phnum_restore_state
 	fi
-	rm -f coredump_phnum_restore_state.sh
+	rm -f cuc
 }
 
 atf_init_test_cases()



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909301405.x8UE5i3w049532>