df: Add --uuid option to print guest UUIDs instead of names (RHBZ#646821).
[libguestfs.git] / test-tool / run-test-tool-locally
1 #!/usr/bin/perl
2 # Copyright (C) 2010 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 # This script sets up the environment so you can run
19 # libguestfs-test-tool in place without needing to do 'make install'
20 # first.  You can also run the test tool by creating a symlink to this
21 # script and putting it in your path.
22 #
23 # Normal use is like this:
24 #   ./run-test-tool-locally
25
26 use strict;
27 use warnings;
28
29 use File::Basename qw(dirname);
30 use File::Spec;
31 use Cwd qw(abs_path);
32
33 my $path = $0;
34 my $tool = shift @ARGV;
35
36 # Follow symlinks until we get to the real file
37 while(-l $path) {
38     my $link = readlink($path) or die "readlink: $path: $!";
39     if(File::Spec->file_name_is_absolute($link)) {
40         $path = $link;
41     } else {
42         $path = File::Spec->catfile(dirname($path), $link);
43     }
44 }
45
46 # Get the absolute path of the parent directory
47 $path = abs_path(dirname($path).'/..');
48
49 $ENV{LD_LIBRARY_PATH} = $path.'/src/.libs';
50 $ENV{LIBGUESTFS_PATH} = $path.'/appliance';
51
52 exec("$path/test-tool/libguestfs-test-tool",
53      "$path/test-tool/libguestfs-test-tool",
54      "--helper",
55      "$path/test-tool/libguestfs-test-tool-helper",
56      @ARGV);