Skip to contentSkip to conversation

overlay: deprecate test t_truncate_self

PATCH In review Amir Goldstein 2 participants 2 messages Aug 30, 2024 – Sep 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 overlay: deprecate test t_truncate_self

Since kernel commit 2a010c412853 ("fs: don't block i_writecount during exec"), truncating an executable file while it is being executed is allowed. Therefore, the test t_truncate_self now fails, so remove it.

---

Zorro,

This is a fix for a test regression since v6.11-rc1.
My fix is to deprecate the test, because the change of behavior is desired (at least until a non test user complains).

Thanks,
Amir.

 .gitignore            |  1 -
 src/Makefile          |  2 +-
 src/t_truncate_self.c | 26 --------------------------
 tests/overlay/013     | 41 -----------------------------------------
 tests/overlay/013.out |  2 --
 5 files changed, 1 insertion(+), 71 deletions(-)
 delete mode 100644 src/t_truncate_self.c
 delete mode 100755 tests/overlay/013
 delete mode 100644 tests/overlay/013.out
.gitignore +0 -1
index 36083e9d..94f6b564 100644
@@ -171,7 +171,6 @@ tags
 /src/t_snapshot_deleted_subvolume
 /src/t_stripealign
 /src/t_truncate_cmtime
-/src/t_truncate_self
 /src/test-nextquota
 /src/testx
 /src/trunc
src/Makefile +1 -1
index b3da59a0..52299b4c 100644
@@ -13,7 +13,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	godown resvtest writemod writev_on_pagefault makeextents itrash rename \
 	multi_open_unlink unwritten_sync genhashnames t_holes \
 	t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \
-	holetest t_truncate_self af_unix t_mmap_stale_pmd \
+	holetest af_unix t_mmap_stale_pmd \
 	t_mmap_cow_race t_mmap_fallocate fsync-err t_mmap_write_ro \
 	t_ext4_dax_journal_corruption t_ext4_dax_inline_corruption \
 	t_ofd_locks t_mmap_collision mmap-write-concurrent \
src/t_truncate_self.c deleted +0 -26
deleted file mode 100644
index a11f7d5a..00000000
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <libgen.h>
-
-int main(int argc, char *argv[])
-{
-	const char *progname = basename(argv[0]);
-	int ret;
-
-	ret = truncate(argv[0], 4096);
-	if (ret != -1) {
-		if (argc == 2 && strcmp(argv[1], "--may-succeed") == 0)
-			return 0;
-		fprintf(stderr, "truncate(%s) should have failed\n",
-			progname);
-		return 1;
-	}
-	if (errno != ETXTBSY) {
-		perror(progname);
-		return 1;
-	}
-
-	return 0;
-}
tests/overlay/013 deleted +0 -41

41 lines not on this page · raw message

tests/overlay/013.out deleted +0 -2
deleted file mode 100644
index 3e66423b..00000000
@@ -1,2 +0,0 @@
-QA output created by 013
-Silence is golden
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Amir Goldstein

Since kernel commit 2a010c412853 ("fs: don't block i_writecount during exec"), truncating an executable file while it is being executed is allowed. Therefore, the test t_truncate_self now fails, so remove it.

Quoted 8 lines

---

Zorro,

This is a fix for a test regression since v6.11-rc1.
My fix is to deprecate the test, because the change of behavior is desired (at least until a non test user complains).

Makes sense to me,

Quoted 129 lines

Thanks,
Amir.

 .gitignore            |  1 -
 src/Makefile          |  2 +-
 src/t_truncate_self.c | 26 --------------------------
 tests/overlay/013     | 41 -----------------------------------------
 tests/overlay/013.out |  2 --
 5 files changed, 1 insertion(+), 71 deletions(-)
 delete mode 100644 src/t_truncate_self.c
 delete mode 100755 tests/overlay/013
 delete mode 100644 tests/overlay/013.out
.gitignore +0 -1
index 36083e9d..94f6b564 100644
@@ -171,7 +171,6 @@ tags
 /src/t_snapshot_deleted_subvolume
 /src/t_stripealign
 /src/t_truncate_cmtime
-/src/t_truncate_self
 /src/test-nextquota
 /src/testx
 /src/trunc
src/Makefile +1 -1
index b3da59a0..52299b4c 100644
@@ -13,7 +13,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	godown resvtest writemod writev_on_pagefault makeextents itrash rename \
 	multi_open_unlink unwritten_sync genhashnames t_holes \
 	t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \
-	holetest t_truncate_self af_unix t_mmap_stale_pmd \
+	holetest af_unix t_mmap_stale_pmd \
 	t_mmap_cow_race t_mmap_fallocate fsync-err t_mmap_write_ro \
 	t_ext4_dax_journal_corruption t_ext4_dax_inline_corruption \
 	t_ofd_locks t_mmap_collision mmap-write-concurrent \
src/t_truncate_self.c deleted +0 -26
deleted file mode 100644
index a11f7d5a..00000000
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <libgen.h>
-
-int main(int argc, char *argv[])
-{
-	const char *progname = basename(argv[0]);
-	int ret;
-
-	ret = truncate(argv[0], 4096);
-	if (ret != -1) {
-		if (argc == 2 && strcmp(argv[1], "--may-succeed") == 0)
-			return 0;
-		fprintf(stderr, "truncate(%s) should have failed\n",
-			progname);
-		return 1;
-	}
-	if (errno != ETXTBSY) {
-		perror(progname);
-		return 1;
-	}
-
-	return 0;
-}
tests/overlay/013 deleted +0 -41
deleted file mode 100755
index 73c72c30..00000000
@@ -1,41 +0,0 @@
-#! /bin/bash
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
-#
-# FS QA Test 013
-#
-# Test truncate running executable binaries from lower and upper dirs.
-# truncate(2) should return ETXTBSY, not other errno nor segfault
-#
-# Commit 03bea6040932 ("ovl: get_write_access() in truncate") fixed this issue.
-. ./common/preamble
-_begin_fstest auto quick copyup
-
-# Import common functions.
-. ./common/filter
-
-_require_scratch
-_require_test_program "t_truncate_self"
-
-# remove all files from previous runs
-_scratch_mkfs
-
-# copy test program to lower and upper dir
-lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
-upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
-mkdir -p $lowerdir
-mkdir -p $upperdir
-cp $here/src/t_truncate_self $lowerdir/test_lower
-cp $here/src/t_truncate_self $upperdir/test_upper
-
-_scratch_mount
-
-# run test program from lower and upper dir
-# test programs truncate themselfs, all should fail with ETXTBSY
-$SCRATCH_MNT/test_lower --may-succeed
-$SCRATCH_MNT/test_upper
-
-# success, all done
-echo "Silence is golden"
-status=0
-exit
tests/overlay/013.out deleted +0 -2
deleted file mode 100644
index 3e66423b..00000000
@@ -1,2 +0,0 @@
-QA output created by 013
-Silence is golden
Signature · 1 line
2.34.1