#!/usr/bin/env ruby
$LOAD_PATH.unshift('.')
require 'raid/baseraid'

DISK_GROUP_SIZE=ARGV[0].to_i
GROUP_NUMBER=ARGV[1].to_i

RAID::BaseRaid::query_adapters.each { |ad|
	a = RAID::RAIDS[ad[:driver]].new(ad[:num])
	a.logical_clear
	pl = a._physical_list.keys.sort

	if (DISK_GROUP_SIZE != 0) then
		exit 1 if pl.length <= (DISK_GROUP_SIZE * GROUP_NUMBER)
	end

	if (DISK_GROUP_SIZE != 0) then
		now_testing = pl[ (DISK_GROUP_SIZE * GROUP_NUMBER) .. (DISK_GROUP_SIZE * (GROUP_NUMBER+1)-1) ]
	else
		now_testing = pl
	end
	now_testing.compact!
	puts "Testing #{now_testing.join(',')}"

	a.logical_clear
	now_testing.each { |disc|
		a.logical_add('passthrough', disc, nil)
	}
	a.adapter_restart
	a.logical_list
}
