Skip to content

Commit

Permalink
bin/setup-local: introduce --dry-run option
Browse files Browse the repository at this point in the history
get the steps with '--dry-run' option
--------------
root@shao2-debian:/lkp-tests# bin/setup-local -s borrow-1h-1h.yaml 2>/dev/null
cd /lkp-tests/bin/event && make wakeup
mkdir -p /lkp-tests/tmp /lkp/paths /lkp/benchmarks
/lkp-tests/distro/installer/debian bc gawk time kmod gzip make automake gcc build-essential libtool patch git openssl linux-perf ca-certificates rsync cpio wget libklibc-dev linux-libc-dev linux-libc-dev:i386 libc6-dev libc6-dev:i386 ruby ruby-dev bzip2 bsdtar fakeroot flex bison libssl-dev libipc-run-perl
/lkp-tests/distro/installer/debian curl bsdtar bzip2 fakeroot gnupg gettext openssl ncurses-bin binutils
/lkp-tests/distro/installer/debian procps
--------------

Signed-off-by: Chen Rong <[email protected]>
Signed-off-by: Philip Li <[email protected]>
  • Loading branch information
xilabao authored and rli9 committed Oct 18, 2019
1 parent d24c6af commit 42847d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bin/setup-local
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require "#{LKP_SRC}/lib/yaml"
require "#{LKP_SRC}/lib/job"
require "#{LKP_SRC}/lib/distro-info"
require "#{LKP_SRC}/lib/install"
require "#{LKP_SRC}/lib/common"

TMP = LKP_SRC + '/tmp'

Expand All @@ -22,6 +23,7 @@ end

$opt_hdd = []
$opt_ssd = []
$dryrun = false

opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: setup-local [options] <script>/<jobfile>'
Expand All @@ -37,6 +39,12 @@ opt_parser = OptionParser.new do |opts|
$opt_ssd << ssd
end

opts.on('-s', '--dry-run', 'Perform a simulation of events') do
alias system puts_stdout # only output system commands to stdout
alias puts puts_stderr # redirect logs to stderr to leave stdout to commands
$dryrun = true
end

opts.on_tail('-h', '--help', 'Show this message') do
puts opts
exit
Expand Down Expand Up @@ -70,12 +78,16 @@ end
scripts.uniq!

def make_wakeup
return if File.executable? LKP_SRC + '/bin/event/wakeup'
return if !$dryrun && File.executable?(LKP_SRC + '/bin/event/wakeup')

system "cd #{LKP_SRC}/bin/event && make wakeup"
end

def create_lkp_dirs
if $dryrun
system "mkdir -p #{TMP} /lkp/paths /lkp/benchmarks"
return
end
FileUtils.mkdir_p TMP
FileUtils.mkdir_p '/lkp/paths'
FileUtils.mkdir_p '/lkp/benchmarks'
Expand All @@ -86,6 +98,7 @@ def create_host_config
if File.exist? host_config
puts 'reusing ' + host_config
else
puts 'creating ' + host_config
mem_kb = File.open('/proc/meminfo').gets.split[1].to_i
mem_gb = mem_kb >> 20
mem_gb = (mem_gb + 3) & 0xfffffffc
Expand Down
10 changes: 10 additions & 0 deletions lib/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ def bash

## IO redirection

def puts_stdout(*args)
$stdout.puts *args.join(' ')
return 0
end

def puts_stderr(*args)
$stderr.puts *args.join(' ')
return 0
end

def redirect_to(io)
saved_stdout = $stdout
$stdout = io
Expand Down

0 comments on commit 42847d5

Please sign in to comment.