File: 0010-interfaces-prompting-handle-unsupported-xattrs.patch

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (78 lines) | stat: -rw-r--r-- 2,611 bytes parent folder | download
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
78
From: Zygmunt Krynicki <me@zygoon.pl>
Date: Thu, 21 Aug 2025 18:41:55 +0000
Subject: interfaces/prompting: handle unsupported xattrs

This happens in Debian build infrastructure:
```
FAIL: requestrules_test.go:748: requestrulesSuite.TestReadOrAssignUserSessionID

requestrules_test.go:765:
    c.Assert(err, IsNil)
... value syscall.Errno = 0x5f ("operation not supported")
```

Most likely the file system under /run is not a tmpfs or is restricted by a
sandbox of some sort. Allow tests to detect this condition and skip certain
parts.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
---
 .../prompting/requestrules/requestrules_test.go       | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/interfaces/prompting/requestrules/requestrules_test.go b/interfaces/prompting/requestrules/requestrules_test.go
index 9f66c1d..b83f24c 100644
--- a/interfaces/prompting/requestrules/requestrules_test.go
+++ b/interfaces/prompting/requestrules/requestrules_test.go
@@ -28,6 +28,7 @@ import (
 	"sort"
 	"strings"
 	"sync"
+	"syscall"
 	"testing"
 	"time"
 
@@ -762,6 +763,9 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionID(c *C) {
 
 	// If there is a user session dir, expect some non-zero user ID
 	origID, err := rdb.ReadOrAssignUserSessionID(1000)
+	if errors.Is(err, syscall.EOPNOTSUPP) {
+		c.Skip("xttrs are not supported on this system")
+	}
 	c.Assert(err, IsNil)
 	c.Assert(origID, Not(Equals), prompting.IDType(0))
 
@@ -840,14 +844,18 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionIDConcurrent(c *C) {
 	var startWG sync.WaitGroup
 	startWG.Add(count)
 	resultChan := make(chan prompting.IDType, count)
+	errChan := make(chan error, count)
 	for i := 0; i < count; i++ {
 		go func() {
 			startWG.Done()
 			<-startChan // wait for broadcast
 			sessionID, err := rdb.ReadOrAssignUserSessionID(5000)
-			c.Assert(err, IsNil)
-			c.Assert(sessionID, Not(Equals), prompting.IDType(0))
-			resultChan <- sessionID
+			if err != nil {
+				errChan <- err
+			} else {
+				c.Assert(sessionID, Not(Equals), prompting.IDType(0))
+				resultChan <- sessionID
+			}
 		}()
 	}
 	startWG.Wait()
@@ -861,6 +869,11 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionIDConcurrent(c *C) {
 	case firstID = <-resultChan:
 		c.Assert(firstID, NotNil)
 		c.Assert(firstID, Not(Equals), prompting.IDType(0))
+	case err := <-errChan:
+		if errors.Is(err, syscall.EOPNOTSUPP) {
+			c.Skip("xttrs are not supported on this system")
+		}
+		c.Assert(err, IsNil)
 	case <-time.NewTimer(time.Second).C:
 		c.Fatal("timed out waiting for first user ID")
 	}