-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests
More file actions
executable file
·146 lines (135 loc) · 3.94 KB
/
runtests
File metadata and controls
executable file
·146 lines (135 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env perl
# Copyright (c) 2008-2020 Message Systems, Inc.
# Runs unit tests
# vim:ts=2:sw=2:et:
use strict;
use warnings;
use File::Find;
use Data::Dumper;
use Getopt::Long;
use IO::File;
use lib '.';
use t::strap;
use t::TAP_Harness;
BEGIN {
$ENV{HARNESS_STRAP_CLASS} = "t::strap";
$ENV{HARNESS_SUBCLASS} = "t::TAP_Harness";
}
use Test::Harness;
my $use_installed = 0;
my $quiet = 0;
my $valgrind = 0;
GetOptions(
"compare" => \$use_installed,
"valgrind|g" => \$valgrind,
"quiet" => \$quiet
);
# in order to run sensibly on different versions of perl, we use the old
# way of poking the strap (so that we can run lua bits intelligently).
# we have to save the callback that was set on the default strap and
# attach that to the new strap for test output to show up
my $strap_callback = $Test::Harness::Strap->{callback};
$Test::Harness::Strap = t::strap->new;
$Test::Harness::Strap->{callback} = $strap_callback;
$Test::Harness::verbose = !$quiet;
$ENV{'TEST_VERBOSE'} = 1 if !$quiet;
$ENV{'HARNESS_VERBOSE'} = 1 if !$quiet;
$ENV{'USE_VALGRIND'} = 1 if $valgrind;
use Config;
$ENV{RCLUA_INIT} = <<LUA;
platform = {
osname=[[$Config{osname}]],
}
LUA
my $INSTALLED_LUA = "/opt/msys/3rdParty/bin/rclua";
$ENV{RCLUA_PATH} = './?.lua;./etc/?.lua;./etc/?/init.lua';
$ENV{LUA_PATH} = './?.lua;./etc/?.lua;./etc/?/init.lua';
$ENV{RCLUA_CPATH} = ".libs/?.so";
if ($use_installed) {
$ENV{LUA_EXECUTABLE} ||= $INSTALLED_LUA;
} else {
$ENV{DYLD_LIBRARY_PATH} = ".libs";
$ENV{LD_LIBRARY_PATH} = ".libs";
$ENV{LUA_EXECUTABLE} ||= ".libs/rclua";
if (-x $INSTALLED_LUA) {
# If Lua is installed, it will be picked up by the test harness.
# It's not possible to avoid this, because we link libraries
# using -rpath. LD_LIBRARY_PATH cannot override -rpath.
# Installed Lua needs to be removed before we can run tests.
print STDERR <<'EOT';
!!! !!!
!!! LUA IS INSTALLED - THIS WILL INTERFERE WITH TESTS !!!
!!! !!!
!!! Please remove it before running the tests. !!!
!!! This can be achieved using: !!!
!!! !!!
!!! sudo rpm -ev msys-lua msys-lua-devel --nodeps !!!
!!! !!!
!!! Once you've finished with your Lua development, !!!
!!! reinstall Lua using your Core repo checkout. !!!
!!! E.g.: !!!
!!! !!!
!!! cd /path/to/Core !!!
!!! ./build/check !!!
!!! !!!
EOT
}
}
$ENV{THIS_ENV_VAR_IS_SET_FOR_THE_ENV_TEST} = "w00t";
my @tests;
@ARGV = "t" unless @ARGV;
foreach (@ARGV) {
find(sub {
next if $_ eq '.hg';
next if $_ eq '.svn';
next if $_ eq 'CVS';
if (m/\.(lua|t|luat)$/ and -f $_) {
push @tests, $File::Find::name;
}
}, $_);
}
runtests(@tests);
if ($valgrind) {
my $res = {};
my $loss = 0;
my $bad = 0;
foreach my $test (@tests) {
my $log = $test . '.vglog';
if (-f $log) {
my $fh = IO::File->new($log);
my $out = 0;
my $badmem = 0;
while (<$fh>) {
if (m/(definitely|indirectly|possibly) lost: (\d+) bytes in \d+ blocks/)
{
my $amount = $2;
if ($amount == 0) {
next;
}
if ($1 eq 'definitely') {
$loss += $amount;
}
if (!$out) {
print "\n$test:\n";
$out = 1;
}
print $_;
}
if (m/Invalid (read|write) of size/) {
$bad++;
if (!$out) {
print "\n$test:\n";
$out = 1;
}
if (!$badmem) {
print "$_\n";
$badmem++;
}
}
}
}
}
if (!$loss) {
print "\nValgrind says everything is clean\n";
}
}