File tree Expand file tree Collapse file tree 5 files changed +74
-0
lines changed
testsuite/tests/traces/env_var_substitution Expand file tree Collapse file tree 5 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ trace_pid > log_pid.$$
2+ trace_D > log_D.$D
3+ trace_T > log_T.$T
4+ trace_FOO > log_FOO.$FOO
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import glob
4+
5+
6+ pid = int (open ('tracename.pid' ).readline ())
7+ for pat in ['log_pid.%d' % pid ,
8+ 'log_D.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' ,
9+ 'log_T.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' +
10+ 'T[0-9][0-9][0-9][0-9][0-9][0-9]' ,
11+ 'log_FOO.BAR' ]:
12+ files = glob .glob (pat )
13+ if len (files ) != 1 :
14+ print ("expected 1 file matching %s, found %d"
15+ % (pat , len (files )))
16+ fnam = files [0 ]
17+ if "hello from %d" % pid not in open (fnam ).readline ():
18+ print ("Marker not found in %s" % fnam )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import os
4+ import glob
5+
6+
7+ def unlink_if_exists (files ):
8+ if isinstance (files , str ):
9+ files = [files ]
10+ for f in files :
11+ try :
12+ os .unlink (f )
13+ except OSError :
14+ pass
15+
16+ map (os .unlink , glob .glob ("log_*" ))
17+ unlink_if_exists ("tracename.pid" )
18+
Original file line number Diff line number Diff line change 1+ with GNATCOLL.Traces ; use GNATCOLL.Traces;
2+ with Test_Assert ;
3+ with Ada.Text_IO ; use Ada.Text_IO;
4+ with Ada.Environment_Variables ;
5+
6+ function Test return Integer is
7+ H_PID : constant Trace_Handle := Create (" trace_pid" );
8+ H_D : constant Trace_Handle := Create (" trace_D" );
9+ H_T : constant Trace_Handle := Create (" trace_T" );
10+ H_FOO : constant Trace_Handle := Create (" trace_FOO" );
11+ function getpid return Integer;
12+ pragma Import (C, getpid, " getpid" );
13+
14+ Pid : constant String := getpid'Img;
15+ Pidfile : Ada.Text_IO.File_Type;
16+ begin
17+ Create (Pidfile, Out_File, " tracename.pid" );
18+ Put_Line (Pidfile, Pid);
19+ Close (Pidfile);
20+
21+ Ada.Environment_Variables.Set (" FOO" , " BAR" );
22+
23+ Parse_Config_File;
24+ Trace (H_PID, " hello from" & Pid);
25+ Trace (H_D, " hello from" & Pid);
26+ Trace (H_T, " hello from" & Pid);
27+ Trace (H_FOO, " hello from" & Pid);
28+
29+ return Test_Assert.Report;
30+ end Test ;
Original file line number Diff line number Diff line change 1+ title : GNATCOLL.Traces test
2+ data : [".gnatdebug"]
3+ control :
4+ - [SKIP, "env.is_cross", "Test uses python which is not available on cross targets"]
You can’t perform that action at this time.
0 commit comments