[107928] branches/gsoc13-tests/tests/test
marius at macports.org
marius at macports.org
Tue Jul 9 08:59:44 PDT 2013
Revision: 107928
https://trac.macports.org/changeset/107928
Author: marius at macports.org
Date: 2013-07-09 08:59:44 -0700 (Tue, 09 Jul 2013)
Log Message:
-----------
Added non-working version of trace test.
Modified Paths:
--------------
branches/gsoc13-tests/tests/test/library.tcl
branches/gsoc13-tests/tests/test/trace/Portfile
branches/gsoc13-tests/tests/test/trace/test.tcl
Modified: branches/gsoc13-tests/tests/test/library.tcl
===================================================================
--- branches/gsoc13-tests/tests/test/library.tcl 2013-07-09 13:59:35 UTC (rev 107927)
+++ branches/gsoc13-tests/tests/test/library.tcl 2013-07-09 15:59:44 UTC (rev 107928)
@@ -1,5 +1,4 @@
set autoconf [file dirname $argv0]/../../../Mk/macports.autoconf.mk
-
eval ::tcltest::configure $::argv
set output_file "output"
@@ -116,6 +115,25 @@
return $result
}
+# Runs port trace.
+proc port_trace {pwd} {
+ global bindir
+ global datadir
+ global portsrc
+
+ set back [pwd]
+ cd $pwd
+
+ set env "env PORTSRC=${portsrc}"
+ set cmd "port"
+ set args "-t test"
+ set output "output"
+
+ set result [catch {eval exec $env $bindir$cmd $args >&output 2>@1} ]
+ cd $back
+ return $result
+}
+
# Installs new portfile.
proc port_install {} {
global bindir
Modified: branches/gsoc13-tests/tests/test/trace/Portfile
===================================================================
--- branches/gsoc13-tests/tests/test/trace/Portfile 2013-07-09 13:59:35 UTC (rev 107927)
+++ branches/gsoc13-tests/tests/test/trace/Portfile 2013-07-09 15:59:44 UTC (rev 107928)
@@ -1,33 +1,55 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil;
+# c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$
-PortSystem 1.0
-name trace
-version 1
-categories test
-maintainers pguyot at kallisys.net
-description Test port for -t
-homepage http://www.macports.org/
-platforms darwin
+PortSystem 1.0
+name trace
+version 1
+categories test
+maintainers pguyot at kallisys.net
+description Test port for -t
+homepage http://www.macports.org/
+platforms darwin
-long_description ${description}
+long_description ${description}
distfiles
-use_configure no
-build {}
-destroot {
- system "touch ${destroot}${prefix}/lib/${name}"
+use_configure no
+build {}
+destroot {
+ system "touch ${destroot}${prefix}/lib/${name}"
}
test {
- catch {system "touch create-trace"}
- catch {system "rm delete-trace"}
- system "touch /tmp/hello-trace"
- system "rm /tmp/hello-trace"
- system "ln -s /usr/include/ link-trace"
- system "rm /tmp/link-trace2"
- catch {system "mkdir mkdir-trace"}
- catch {system "rmdir rmdir-trace"}
- catch {system "mv rename-trace rename-new-trace"}
- catch {system "DYLD_INSERT_LIBRARIES= touch create-trace-modenv"}
- system "mkdir -p /usr/bin"
+ proc fails {operation} {
+ if {![catch $operation]} {
+ ui_error "Operation ${operation} succeeded although it should have
+failed!"
+ error "test failure"
+ }
+ }
+ # the port directory is outside of the sandbox; make sure files can't be
+ # created, deleted or symlinked into place here
+ fails {system "touch ../tracetesttmp/create-trace"}
+ fails {system "rm ../tracetesttmp/delete-trace"}
+ fails {system "ln -s /usr/include/ ../tracetesttmp/link-trace"}
+ # we also don't want mkdir or rmdir here
+ fails {system "mkdir ../tracetesttmp/mkdir-trace"}
+ fails {system "rmdir ../tracetesttmp/rmdir-trace"}
+ # renaming should also be prohibited
+ fails {system "mv ../tracetesttmp/rename-trace
+../tracetesttmp/rename-new-trace"}
+
+ # test access to /tmp
+ system "touch /tmp/hello-trace"
+ system "rm /tmp/hello-trace"
+ system "rm /tmp/link-trace2"
+
+ # overwriting DYLD_INSERT_LIBRARIES should not allow escaping the sandbox
+ # (due to env restoring)
+ fails {system "DYLD_INSERT_LIBRARIES= touch
+../tracetesttmp/create-trace-modenv"}
+
+ # if the directories already exist, mkdir -p should succeed.
+ system "mkdir -p /usr/bin"
}
Modified: branches/gsoc13-tests/tests/test/trace/test.tcl
===================================================================
--- branches/gsoc13-tests/tests/test/trace/test.tcl 2013-07-09 13:59:35 UTC (rev 107927)
+++ branches/gsoc13-tests/tests/test/trace/test.tcl 2013-07-09 15:59:44 UTC (rev 107928)
@@ -15,26 +15,19 @@
port_index
port_clean $path
- makeFile "" delete-trace
- makeFile "" rename-trace
- makeDirectory rmdir-trace
+ exec mkdir ../tracetesttmp
+ exec chown macports ../tracetesttmp
+ exec sudo -u macports touch ../tracetesttmp/delete-trace
+ exec sudo -u macports touch ../tracetesttmp/rename-trace
+ exec sudo -u macports mkdir ../tracetesttmp/rmdir-trace
+ file delete -force /tmp/hello-trace
file link -symbolic /tmp/link-trace2 /usr/include/unistd.h
+ exec chown -h macports /tmp/link-trace2
- file delete -force create-trace
- file delete -force create-trace-modenv
- file delete -force mkdir-trace
- file delete -force /tmp/hello-trace
- file delete -force link-trace
+ port_trace $path
- port_run $path
-
- file delete -force link-trace
- file delete -force rename-new-trace
- file delete -force create-trace
- file delete -force create-trace-modenv
- file delete -force mkdir-trace
+ file delete -force /tmp/link-trace2
file delete -force /tmp/hello-trace
- file delete -force /tmp/link-trace
}
test trace {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130709/ace75204/attachment.html>
More information about the macports-changes
mailing list