citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 6e399f04953de6e2243dfd3fabe56c48c8f5066f
parent 8511c9a29c9a8b8e51109394f99a1e2bf05ca13f
Author: Kyle Milz <kyle@windows.krwm.net>
Date:   Fri,  6 Jan 2017 21:20:48 -0800

t: remove File::Util use

Diffstat:
Mlib.c | 7++++---
Mt/utils.pm | 18++++--------------
2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/lib.c b/lib.c @@ -19,7 +19,7 @@ #include <windows.h> /* HANDLE, MapViewOfFile, ... */ #include <io.h> #define PATH_MAX 32000 -#define DEFAULT_PROCDIR "C:\\CItRun\\" +#define DEFAULT_PROCDIR "C:\\CItRun" #else /* _WIN32 */ #include <sys/mman.h> /* mmap */ #include <sys/stat.h> /* S_IRUSR, S_IWUSR, mkdir */ @@ -32,7 +32,7 @@ #include <stdlib.h> /* atexit, get{env,progname} */ #include <string.h> /* str{l,n}cpy */ #include <unistd.h> /* lseek get{cwd,pid,ppid,pgrp} */ -#define DEFAULT_PROCDIR "/tmp/citrun/" +#define DEFAULT_PROCDIR "/tmp/citrun" #endif /* _WIN32 */ #include "lib.h" /* citrun_*, struct citrun_{header,node} */ @@ -175,7 +175,6 @@ open_fd() char *procdir; char procfile[PATH_MAX]; - /* User of this env var must give trailing slash */ if ((procdir = getenv("CITRUN_PROCDIR")) == NULL) procdir = DEFAULT_PROCDIR; @@ -185,6 +184,7 @@ open_fd() Err(1, "CreateDirectory"); strncpy(procfile, procdir, PATH_MAX); + strncat(procfile, "\\", PATH_MAX); strncat(procfile, "program", PATH_MAX); strncat(procfile, "_XXXXXXXXXX", PATH_MAX); @@ -195,6 +195,7 @@ open_fd() err(1, "mkdir '%s'", procdir); strlcpy(procfile, procdir, PATH_MAX); + strlcat(procfile, "/", PATH_MAX); strlcat(procfile, getprogname(), PATH_MAX); strlcat(procfile, "_XXXXXXXXXX", PATH_MAX); diff --git a/t/utils.pm b/t/utils.pm @@ -1,6 +1,6 @@ use strict; use warnings; -use File::Util; +use if $^O eq "MSWin32", 'File::DosGlob' => 'glob'; use Test::Cmd; use Test::Differences; use Test::More; @@ -20,27 +20,17 @@ sub clean_citrun_log { sub get_one_shmfile { my ($dir) = @_; - opendir( DIR, $dir ) or die $!; - my @files; - for (readdir(DIR)) { - next if ($_ eq "."); - next if ($_ eq ".."); - push @files, ($_); - } - - closedir(DIR); + my @files = glob File::Spec->catfile( $dir, "program_*"); die "not exactly one procfile found" if (scalar @files != 1); - return File::Spec->catfile( $dir, $files[0] ); + return $files[0]; } sub setup_projdir { my $wrap = Test::Cmd->new( prog => 'citrun_wrap', workdir => '' ); - - $ENV{CITRUN_PROCDIR} = File::Spec->catdir( $wrap->workdir, "procdir" ); - $ENV{CITRUN_PROCDIR} .= File::Util->SL; + $ENV{CITRUN_PROCDIR} = $wrap->workdir; $wrap->write( 'main.c', <<EOF); #include <stdio.h>