commit 5757897eb351669a45122946738f2d31082af13b
parent b01382356d869011b55976c7959a2847984e41b0
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Fri, 25 Mar 2016 16:20:47 -0600
tt: commit vim wip
Diffstat:
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/SCV/Project.pm b/SCV/Project.pm
@@ -1,7 +1,6 @@
package SCV::Project;
use strict;
-use Cwd;
use File::Temp qw( tempdir );
use Test;
use IPC::Open3;
@@ -14,6 +13,7 @@ sub new {
# Make new temporary directory, clean it up at exit
$self->{tmp_dir} = tempdir( CLEANUP => 1 );
$self->{src_files} = [];
+ $self->{prog_name} = "program";
return $self;
}
@@ -38,7 +38,7 @@ sub compile {
my $src_files = join(" ", @{ $self->{src_files} });
my $makefile = <<EOF;
-PROG = program
+PROG = $self->{prog_name}
SRCS = $src_files
MAN =
@@ -89,7 +89,7 @@ sub run {
$ENV{SCV_VIEWER_SOCKET} = "SCV::Viewer.socket";
my $tmp_dir = $self->{tmp_dir};
- $self->{pid} = open3(undef, undef, \*CHLD_ERR, "wrap/scv_wrap", "$tmp_dir/program", @args);
+ $self->{pid} = open3(undef, undef, \*CHLD_ERR, "wrap/scv_wrap", "$tmp_dir/$self->{prog_name}", @args);
}
sub kill {
diff --git a/SCV/Viewer.pm b/SCV/Viewer.pm
@@ -40,6 +40,7 @@ sub get_metadata {
my ($pid, $ppid, $pgrp) = unpack("L3", $buf);
my $runtime_metadata = {
+ num_tus => $num_tus,
pid => $pid,
ppid => $ppid,
pgrp => $pgrp,
diff --git a/tt/vim.t b/tt/vim.t
@@ -0,0 +1,43 @@
+use strict;
+use SCV::Project;
+use SCV::Viewer;
+use Test::More tests => 7;
+
+my $viewer = SCV::Viewer->new();
+my $project = SCV::Project->new();
+
+my $tmpdir = $project->get_tmpdir();
+
+my $vim_src = "ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2";
+is( system("cd $tmpdir && curl -O $vim_src"), 0, "download" );
+is( system("cd $tmpdir && tar xjf vim-7.4.tar.bz2"), 0, "extract" );
+
+my $scv_wrap = "wrap/scv_wrap";
+is( system("$scv_wrap make -C $tmpdir/vim74/src scratch"), 0, "make scratch" );
+is( system("$scv_wrap make -C $tmpdir/vim74/src config LIBS=-lscv"), 0, "make config" );
+is( system("rm $tmpdir/vim74/src/SRC_NUMBER"), 0, "rm SRC_NUMBER" );
+system("$scv_wrap make -C $tmpdir/vim74/src myself");
+
+# Launch the newly compiled programs and make sure the runtime is communicating
+$project->{prog_name} = "vim74/src/vim";
+$project->run();
+
+$viewer->accept();
+
+my $runtime_metadata = $viewer->get_metadata();
+is( $runtime_metadata->{num_tus}, 55, "translation unit count" );
+# is( $runtime_metadata->{pid}, 5, "" );
+# is( $runtime_metadata->{ppid}, 5, "" );
+# is( $runtime_metadata->{pgrp}, 5, "" );
+
+my $tus = $runtime_metadata->{tus};
+for (@$tus) {
+ print STDERR "$_->{filename}, $_->{lines} lines, $_->{inst_sites} inst sites\n";
+}
+
+$project->kill();
+$project->wait();
+
+$ENV{SCV_VIEWER_SOCKET} = "SCV::Viewer.socket";
+# Check that the native test suite can pass with instrumented binaries
+is( system("$scv_wrap make -C $tmpdir/vim74/src test"), 0, "make test" );