aboutsummaryrefslogtreecommitdiffstats
path: root/community/pipewire/0003-test-fix-tmpdir-value-after-setenv.patch
blob: fc4c5f2f35cd09d0c8b2bdaa4e3b4aa597f67aa9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From cf3c0431c387a72fdbc66ec78086f695d0b6de3c Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 26 Oct 2021 11:14:06 +1000
Subject: [PATCH 1/2] test: fix tmpdir value after setenv

Introduced in a2856c6e0f692b7a379e06d3ed6ac8107f9b946b

set_test_env() modifies TMPDIR so we must not use getenv until after
that call.

Fixes #1736
---
 test/pwtest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/pwtest.c b/test/pwtest.c
index fbf16cb2f..a000153fd 100644
--- a/test/pwtest.c
+++ b/test/pwtest.c
@@ -915,9 +915,7 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct
 	pid_t pw_daemon = 0;
 	int read_fds[_FD_LAST], write_fds[_FD_LAST];
 	int r;
-	const char *tmpdir = getenv("TMPDIR");
-
-	spa_assert_se(tmpdir != NULL);
+	const char *tmpdir;
 
 	if (t->result == PWTEST_SKIP) {
 		char *buf = pw_array_add(&t->logs[FD_LOG], 64);
@@ -934,6 +932,8 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct
 	}
 
 	set_test_env(ctx, t);
+	tmpdir = getenv("TMPDIR");
+	spa_assert_se(tmpdir != NULL);
 	r = chdir(tmpdir);
 	if (r < 0) {
 		t->sig_or_errno = -errno;
-- 
GitLab


From 07c5511aedf0b0606c0d3f92ce829c5402436d58 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue, 26 Oct 2021 11:03:22 +1000
Subject: [PATCH 2/2] test: handle chdir errors correctly

When we get to this code, we already updated the environment variables
so we need to use the usual error path to restore them.

And where chdir does fail, print an error to the log. 256 chars should
be enough here, if your tmpdir exceeds that you just have the error
message cut off.
---
 test/pwtest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/pwtest.c b/test/pwtest.c
index a000153fd..35e7b003c 100644
--- a/test/pwtest.c
+++ b/test/pwtest.c
@@ -936,8 +936,10 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct
 	spa_assert_se(tmpdir != NULL);
 	r = chdir(tmpdir);
 	if (r < 0) {
+		char *buf = pw_array_add(&t->logs[FD_LOG], 256);
+		spa_scnprintf(buf, 256, "pwtest: failed to chdir to '%s'\n", tmpdir);
 		t->sig_or_errno = -errno;
-		return;
+		goto error;
 	}
 
 	if (t->args.pw_daemon) {
-- 
GitLab