-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'leo/151-array_limit' into 'master'
TGen: Add array size limit beyond which marshallers do not attempt to load them Closes #151 See merge request eng/ide/libadalang-tools!192
- Loading branch information
Showing
9 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
with Ada.Directories; use Ada.Directories; | ||
with Ada.Streams; | ||
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; | ||
with Ada.Text_IO; use Ada.Text_IO; | ||
with Interfaces; use Interfaces; | ||
with My_File; use My_File; | ||
with My_File.TGen_Support; use My_File.TGen_Support; | ||
with TGen.JSON; | ||
with TGen.TGen_Support; use TGen.TGen_Support; | ||
with TGen.Marshalling_Lib; | ||
|
||
procedure Example_Gen is | ||
|
||
Arr : My_Arr (1 .. 10, Mon .. Mon) := | ||
(for I in 1 .. 10 => (Mon => 1)); | ||
|
||
Arr_2 : My_Arr (1 .. 1, Mon .. Sun) := | ||
(1 => (for Day in Weekday => 1)); | ||
|
||
Filename : constant String := "scratchpad.bin"; | ||
File : Ada.Streams.Stream_IO.File_Type; | ||
S : Stream_Access; | ||
begin | ||
Create (File, Out_File, Filename); | ||
S := Stream (File); | ||
TGen_Marshalling_My_File_My_Arr_Output (S, Arr); | ||
Close (File); | ||
Open (File, In_File, Filename); | ||
S := Stream (File); | ||
begin | ||
declare | ||
Arr_In : My_Arr := TGen_Marshalling_My_File_My_Arr_Input (S); | ||
begin | ||
Put_Line ("did not raise an exception when reading array"); | ||
end; | ||
exception | ||
when TGen.Marshalling_Lib.Invalid_Value => null; | ||
end; | ||
Close (File); | ||
Open (File, Out_File, Filename); | ||
S := Stream (File); | ||
TGen_Marshalling_My_File_My_Arr_Output (S, Arr_2); | ||
Close (File); | ||
Open (File, In_File, Filename); | ||
S := Stream (File); | ||
begin | ||
declare | ||
Arr_2_In : My_Arr := TGen_Marshalling_My_File_My_Arr_Input (S); | ||
begin | ||
Put_Line ("did not raise an exception when reading array"); | ||
end; | ||
exception | ||
when TGen.Marshalling_Lib.Invalid_Value => null; | ||
end; | ||
Close (File); | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
LALTOOLS_ROOT=$(dirname $(which gnattest))/.. | ||
TEMPLATES_PATH=$LALTOOLS_ROOT/share/tgen/templates | ||
mkdir -p test/obj obj | ||
# Set a very low limit in the array size, writing arrays over this size is not | ||
# impacted, but we should not be able to read them back. | ||
export TGEN_ARRAY_LIMIT=3 | ||
tgen_marshalling -P test/test.gpr --templates-dir=$TEMPLATES_PATH -o test/tgen_support test/my_file.ads | ||
gprbuild -q -P test_gen.gpr | ||
./obj/example_gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
description: | ||
Test that reading an array from a blob that has a dimension greater | ||
that the limit set through the TGEN_ARRAY_LIMIT environment variable | ||
does raise an exception. | ||
|
||
driver: shell_script | ||
control: | ||
- [XFAIL, 'x86', 'Marshalling not working for 32bits (UB03-008)'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package My_File is | ||
|
||
type Weekday is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); | ||
|
||
type My_Arr is array (Positive range <>, Weekday range <>) of Positive; | ||
|
||
procedure Foo (X : My_Arr) with Import; | ||
|
||
end My_File; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
project Test is | ||
|
||
for Object_Dir use "obj"; | ||
|
||
package Compiler is | ||
for Switches ("ada") use ("-gnat2020"); | ||
end Compiler; | ||
|
||
end Test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
with "test/test.gpr"; | ||
with "test/tgen_support/tgen_support.gpr"; | ||
with "tgen_rts.gpr"; | ||
|
||
project Test_Gen is | ||
|
||
for Main use ("example_gen.adb"); | ||
|
||
for Object_Dir use "obj"; | ||
|
||
package Builder is | ||
for Switches ("ada") use ("-g", "-gnat2022"); | ||
end Builder; | ||
|
||
package Linker is | ||
for Switches ("ada") use ("-g"); | ||
end Linker; | ||
|
||
end Test_Gen; |