commit 32c4573d9074e438f5908009e0d25345386a4a53
parent 102fe24e929e8008983bf3a36d69c5efd925d3be
Author: Kyle Milz <kyle@windows.krwm.net>
Date: Wed, 4 Jan 2017 23:49:08 -0800
t: add win32 compat for lib_size
Diffstat:
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/t/lib_size.t b/t/lib_size.t
@@ -3,19 +3,28 @@
#
use strict;
use warnings;
+use File::DosGlob 'glob';
use POSIX;
-use Test::More tests => 3;
use t::utils;
+plan tests => 5;
-my $tmp_dir = t::tmpdir->new();
-my $ret = system("$tmp_dir/program 1");
-is $ret >> 8, 0, "is test program exit code 0";
+my $dir = setup_projdir();
+
+$dir->run( prog => $dir->workdir . "/program", args => '1', chdir => $dir->curdir );
+is( $? >> 8, 0, "is instrumented program exit code 0" );
my @procfiles = glob("$ENV{CITRUN_PROCDIR}/program_*");
is scalar @procfiles, 1, "is one file in procdir";
my $procfile = t::shm->new($procfiles[0]);
-my $pagesize = POSIX::sysconf(POSIX::_SC_PAGESIZE);
-is($procfile->{size}, $pagesize * 4, "is memory file 4 pages long");
+my $alloc_size;
+if ($^O eq "MSWin32") {
+ # Windows allocation granularity.
+ $alloc_size = 64 * 1024;
+} else {
+ $alloc_size = POSIX::sysconf(POSIX::_SC_PAGESIZE);
+}
+
+is( $procfile->{size}, $alloc_size * 4, "is file 4 allocation units long" );