Skip to content

Commit af4205c

Browse files
author
John Luo
committed
Try chmod the h2spec executable
1 parent 9f969a3 commit af4205c

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/Servers/Kestrel/test/Interop.FunctionalTests/H2SpecCommands.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ namespace Interop.FunctionalTests
1616
{
1717
public static class H2SpecCommands
1818
{
19+
#region chmod
20+
// user permissions
21+
const int S_IRUSR = 0x100;
22+
const int S_IWUSR = 0x80;
23+
const int S_IXUSR = 0x40;
24+
25+
// group permission
26+
const int S_IRGRP = 0x20;
27+
const int S_IWGRP = 0x10;
28+
const int S_IXGRP = 0x8;
29+
30+
// other permissions
31+
const int S_IROTH = 0x4;
32+
const int S_IWOTH = 0x2;
33+
const int S_IXOTH = 0x1;
34+
35+
const int _0755 =
36+
S_IRUSR | S_IXUSR | S_IWUSR
37+
| S_IRGRP | S_IXGRP
38+
| S_IROTH | S_IXOTH;
39+
40+
[DllImport("libc", SetLastError = true)]
41+
private static extern int chmod(string pathname, int mode);
42+
43+
private static int chmod755(string pathname) => chmod(pathname, _0755);
44+
#endregion
45+
1946
private const int TimeoutSeconds = 15;
2047

2148
private static string GetToolLocation()
@@ -27,11 +54,15 @@ private static string GetToolLocation()
2754
}
2855
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
2956
{
30-
return Path.Combine(root, "linux", "h2spec");
57+
var toolPath = Path.Combine(root, "linux", "h2spec");
58+
chmod755(toolPath);
59+
return toolPath;
3160
}
3261
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
3362
{
34-
return Path.Combine(root, "darwin", "h2spec");
63+
var toolPath = Path.Combine(root, "darwin", "h2spec");
64+
chmod755(toolPath);
65+
return toolPath;
3566
}
3667
throw new NotImplementedException("Invalid OS");
3768
}

0 commit comments

Comments
 (0)