|
5 | 5 |
|
6 | 6 | require 'qcow2'
|
7 | 7 | require 'fileutils'
|
| 8 | +require 'systemu' |
8 | 9 |
|
9 |
| -IMAGE_SIZE = 100 * 1024 * 1024 |
| 10 | +IMAGE_SIZE = 1 * 1024 * 1024 |
| 11 | +SHA_1 = '3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3' |
| 12 | +SHA_2 = '7d76d48d64d7ac5411d714a4bb83f37e3e5b8df6' |
10 | 13 |
|
11 | 14 | describe Cangallo::Qcow2 do
|
12 | 15 | before :all do
|
|
65 | 68 | qcow2 = Cangallo::Qcow2.new(@qcow2_path)
|
66 | 69 |
|
67 | 70 | sha1 = qcow2.sha1
|
68 |
| - expect(sha1).to eq('2c2ceccb5ec5574f791d45b63c940cff20550f9a') |
| 71 | + expect(sha1).to eq(SHA_1) |
69 | 72 | end
|
70 | 73 |
|
71 | 74 | it 'should be able to compute sha1 (raw)' do
|
72 | 75 | qcow2 = Cangallo::Qcow2.new(@raw_path)
|
73 | 76 |
|
74 | 77 | sha1 = qcow2.sha1
|
75 |
| - expect(sha1).to eq('2c2ceccb5ec5574f791d45b63c940cff20550f9a') |
| 78 | + expect(sha1).to eq(SHA_1) |
76 | 79 | end
|
77 | 80 | end
|
78 | 81 |
|
|
122 | 125 | qcow2 = Cangallo::Qcow2.new(@qcow2_path)
|
123 | 126 |
|
124 | 127 | sha1 = qcow2.sha1
|
125 |
| - expect(sha1).to eq('fd7c5327c68fcf94b62dc9f58fc1cdb3c8c01258') |
| 128 | + expect(sha1).to eq(SHA_2) |
126 | 129 | end
|
127 | 130 |
|
128 | 131 | it 'should be able to compute sha1 (raw)' do
|
129 | 132 | qcow2 = Cangallo::Qcow2.new(@raw_path)
|
130 | 133 |
|
131 | 134 | sha1 = qcow2.sha1
|
132 |
| - expect(sha1).to eq('fd7c5327c68fcf94b62dc9f58fc1cdb3c8c01258') |
| 135 | + expect(sha1).to eq(SHA_2) |
133 | 136 | end
|
134 | 137 | end
|
135 | 138 |
|
|
199 | 202 | expect(info['backing-filename-format']).to eq(nil)
|
200 | 203 | end
|
201 | 204 | 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 |
202 | 227 | end
|
0 commit comments