Skip to content

Commit a501391

Browse files
committed
Merge branch 'klg/xlinux-windows-hosted' into 'master'
regtests: Fix Windows-to-Linux cross-testing issues See merge request eng/toolchain/aws!11
2 parents 192142f + f883629 commit a501391

File tree

9 files changed

+47
-18
lines changed

9 files changed

+47
-18
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;
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 DEAD "filename = pathname limit"
2+
windows-host DEAD "filename = pathname limit"

regtests/0327_prog_config/test.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
from e3.env import Env
2+
13
from test_support import *
24

3-
with open('aws.ini', 'w') as ini_file:
4-
ini_file.write("status_page aws.ini-status_page\n")
5-
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
5+
def write_aws_ini(config):
6+
newline = None
7+
if Env().host.os.name == "windows" and Env().target.os.name == "linux":
8+
# On Linux, AWS will fail to parse ini files that contain CRLF line-endings: ask
9+
# Python to keep line-feeds verbatim on Windows-hosted cross-Linux testing.
10+
newline = "\n"
11+
12+
with open("aws.ini", "w", newline=newline) as ini_file:
13+
ini_file.write(config)
14+
15+
write_aws_ini("""\
16+
status_page aws.ini-status_page
17+
directory_browser_page aws.ini-directory_browser_page
18+
""")
619

720
build_and_run('prog_config')
821

9-
with open('aws.ini', 'w') as ini_file:
10-
ini_file.write("status_page aws.ini-status_page\n")
11-
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
12-
ini_file.write("disable_program_ini true\n")
22+
write_aws_ini("""\
23+
status_page aws.ini-status_page
24+
directory_browser_page aws.ini-directory_browser_page
25+
disable_program_ini true
26+
""")
1327

1428
run('prog_config')

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)