Commit bc33ed1d authored by Michal Berger's avatar Michal Berger Committed by Jim Harris
Browse files

test/scheduler: Make sure stderr is not O_TRUNCated in move_proc()



Since we are not dup'ing stdout in this case but rather explicitly
point at a file we want to write to, we need to make sure said
file is not suddenly truncated.

In case foo.sh attempts to call to move_proc() and is executed
like so:

foo.sh >bar.log 2>&1

the redirection to /dev/stderr will cause bar.log to be truncated.
This is actually seen under CI after 8571999d got merged as it
removed the SILENT_CGROUP_DEBUG silencer - it causes the build.log
to suddenly drop the trace until remaining tests are finished.
(this happens as jenkins redirects both std{out,err} to a regular
file in a similar fashion).

This can be simply missed when running these tests with std{out,err}
attached to a terminal (as O_TRUNC is ignored there), and so it
unfortunately was while working on the aforementioned commit.

Change-Id: I9d2d5ab87151c3653b0e162aa72b1409418f6fc3
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22967


Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarPawel Piatek <pawelx.piatek@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKamil Godzwon <kamilx.godzwon@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 403c0ec1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ move_proc() {

	[[ -n $SILENT_CGROUP_DEBUG ]] && out=/dev/null

	echo "Moving $proc ($(id_proc "$proc" 2>&1)) to $new_cgroup from $old_cgroup" > "$out"
	echo "Moving $proc ($(id_proc "$proc" 2>&1)) to $new_cgroup from $old_cgroup" >> "$out"
	if ! write_fail=$(set_cgroup_attr "$new_cgroup" "$attr" "$proc" 2>&1); then
		echo "Moving $proc failed: ${write_fail##*: }" > "$out"
		echo "Moving $proc failed: ${write_fail##*: }" >> "$out"
		return 1
	fi
}