Skip to content

Commit 42b9dfc

Browse files
committed
regtests: Fix OS mixup in 0229_deep_resources
test.py and deep_res.adb both use the OS environment variable to determine how long path components should be, since 50 is too long for Windows hosts. However, in a Windows-hosted cross-Linux test, test.py will get one answer, and deep_res.adb another. Fix this by replacing the run-time check in deep_res.adb by a build-time config file selection. Let test_support.build() set the scenario variable to make gprbuild pick the correct file. Amend the test.py check for homogeneity. Change the discriminant, since "NT" is not set when targeting Linux. TN: eng/toolchain/aws#11
1 parent 192142f commit 42b9dfc

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package Config is
2+
Path_Component_Length : Natural := 50;
3+
end Config;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package Config is
2+
Path_Component_Length : Natural := 20;
3+
end Config;

regtests/0229_deep_resources/deep_res.adb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ with Ada.Text_IO;
2323
with AWS.Resources.Embedded;
2424
with AWS.Utils;
2525

26+
with Config;
2627
with rdemo;
2728

2829
procedure Deep_Res is
@@ -42,13 +43,7 @@ procedure Deep_Res is
4243
function Gen (C : Character) return String is
4344
use Ada.Strings.Fixed;
4445
begin
45-
if Environment_Variables.Exists ("OS")
46-
and then Environment_Variables.Value ("OS") = "Windows_NT"
47-
then
48-
return 20 * C;
49-
else
50-
return 50 * C;
51-
end if;
46+
return Config.Path_Component_Length * C;
5247
end Gen;
5348

5449
----------

regtests/0229_deep_resources/deep_res.gpr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,16 @@ project Deep_Res is
2727
for Default_Switches ("Ada") use ("-gnaty", "-gnatwe");
2828
end Compiler;
2929

30+
type OS_Kind is ("linux", "windows");
31+
Host_OS : OS_Kind := external ("Host_OS");
32+
33+
package Naming is
34+
case Host_OS is
35+
when "linux" =>
36+
for Specification ("Config") use "config_linux.ads";
37+
when "windows" =>
38+
for Specification ("Config") use "config_windows.ads";
39+
end case;
40+
end Naming;
41+
3042
end Deep_Res;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
vxworks DEAD "require awsres"
2-
NT OUT test-nt.out
2+
windows-host OUT test-nt.out

regtests/0229_deep_resources/test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from test_support import *
22
import os
33

4+
from e3.env import Env
5+
46
def create_res(name,content):
57
f=open(name,'w')
68
f.write(content)
79
f.close();
810

911
def gen(c):
10-
if os.environ.get("OS") == "Windows_NT":
12+
if Env().host.os.name == "windows":
1113
return c * 20;
1214
else:
1315
return c * 50;

regtests/test_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def tail(infile_name, outfile_name, nb_line):
5757

5858
def build(prj):
5959
"""Compile a project with gprbuild"""
60-
cmd = ["gprbuild"]
60+
cmd = ["gprbuild", f"-XHost_OS={Env().host.os.name}"]
6161
if Env().is_cross:
6262
cmd.append("--target=" + Env().target.triplet)
6363
if Env().target.os.name.startswith("vxworks"):

0 commit comments

Comments
 (0)