Skip to content

Commit bd1f595

Browse files
committed
spec: test creating images with different base formats
Also decreased test image sizes to 1 and 2 MiB
1 parent 981d00d commit bd1f595

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

spec/qcow2_spec.rb

+30-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
require 'qcow2'
77
require 'fileutils'
8+
require 'systemu'
89

9-
IMAGE_SIZE = 100 * 1024 * 1024
10+
IMAGE_SIZE = 1 * 1024 * 1024
11+
SHA_1 = '3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3'
12+
SHA_2 = '7d76d48d64d7ac5411d714a4bb83f37e3e5b8df6'
1013

1114
describe Cangallo::Qcow2 do
1215
before :all do
@@ -65,14 +68,14 @@
6568
qcow2 = Cangallo::Qcow2.new(@qcow2_path)
6669

6770
sha1 = qcow2.sha1
68-
expect(sha1).to eq('2c2ceccb5ec5574f791d45b63c940cff20550f9a')
71+
expect(sha1).to eq(SHA_1)
6972
end
7073

7174
it 'should be able to compute sha1 (raw)' do
7275
qcow2 = Cangallo::Qcow2.new(@raw_path)
7376

7477
sha1 = qcow2.sha1
75-
expect(sha1).to eq('2c2ceccb5ec5574f791d45b63c940cff20550f9a')
78+
expect(sha1).to eq(SHA_1)
7679
end
7780
end
7881

@@ -122,14 +125,14 @@
122125
qcow2 = Cangallo::Qcow2.new(@qcow2_path)
123126

124127
sha1 = qcow2.sha1
125-
expect(sha1).to eq('fd7c5327c68fcf94b62dc9f58fc1cdb3c8c01258')
128+
expect(sha1).to eq(SHA_2)
126129
end
127130

128131
it 'should be able to compute sha1 (raw)' do
129132
qcow2 = Cangallo::Qcow2.new(@raw_path)
130133

131134
sha1 = qcow2.sha1
132-
expect(sha1).to eq('fd7c5327c68fcf94b62dc9f58fc1cdb3c8c01258')
135+
expect(sha1).to eq(SHA_2)
133136
end
134137
end
135138

@@ -199,4 +202,26 @@
199202
expect(info['backing-filename-format']).to eq(nil)
200203
end
201204
end
205+
206+
context 'different backing image formats' do
207+
before :all do
208+
formats = ['qcow', 'qcow2', 'qed', 'raw', 'vmdk', 'vdi', 'vhdx']
209+
@images = []
210+
211+
formats.each do |format|
212+
name = File.join(@tmpdir, "base_format.#{format}")
213+
@images << name
214+
cmd = "qemu-img create -f #{format} #{name} #{IMAGE_SIZE}"
215+
pr = systemu cmd
216+
expect(pr[0].success?).to eq(true)
217+
end
218+
end
219+
220+
it 'should be able to create chained images' do
221+
@images.each do |image|
222+
name = "#{image}.chained"
223+
Cangallo::Qcow2.create(name, image, IMAGE_SIZE)
224+
end
225+
end
226+
end
202227
end

0 commit comments

Comments
 (0)