diff --git a/.travis.yml b/.travis.yml index 62d878530..fddd36443 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ before_install: # disable rvm, use system Ruby - rvm reset - wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh - - sh ./travis_setup.sh -p "rake yast2-core-dev yast2 yast2-devtools doxygen yast2-testsuite libstorage5-dev libstorage5-ruby ruby-dbus" -g "rspec:3.3.0 yast-rake gettext" + - sh ./travis_setup.sh -p "rake yast2-core-dev yast2 yast2-devtools doxygen yast2-testsuite libstorage5-dev libstorage5-ruby ruby-dbus" -g "rspec:3.3.0 yast-rake gettext cheetah abstract_method" script: - rake check:syntax - rake check:pot diff --git a/src/modules/FileSystems.rb b/src/modules/FileSystems.rb index abecb09f2..75645f9e5 100644 --- a/src/modules/FileSystems.rb +++ b/src/modules/FileSystems.rb @@ -31,9 +31,18 @@ # $Id$ require "storage" require "yast" +require "yast2/execute" module Yast class FileSystemsClass < Module + include Yast::Logger + + # @return [Array] Supported default subvolume names + SUPPORTED_DEFAULT_SUBVOLUME_NAMES = ["", "@"].freeze + + # @return [String] Default subvolume name. + attr_reader :default_subvol + def main textdomain "storage" @@ -44,6 +53,7 @@ def main Yast.import "Encoding" Yast.import "Stage" Yast.import "StorageInit" + Yast.import "ProductFeatures" @conv_fs = { "def_sym" => :unknown, @@ -74,7 +84,8 @@ def main @possible_root_fs = [:ext2, :ext3, :ext4, :btrfs, :reiser, :xfs] @swap_m_points = ["swap"] @tmp_m_points = ["/tmp", "/var/tmp"] - @default_subvol = "UNDEFINED" + self.default_subvol = ProductFeatures.GetStringFeature("partitioning", "btrfs_default_subvolume") + @suggest_m_points = [] @suggest_tmp_points = [] @@ -1439,7 +1450,7 @@ def FileSystems def InitSlib(value) @sint = value if @sint != nil - @default_subvol = @sint.getDefaultSubvolName() + @sint.setDefaultSubvolName(@default_subvol) Builtins.y2milestone( "InitSlib used default_subvol:\"%1\"", @default_subvol @@ -2030,14 +2041,86 @@ def AddQuotaOpts(part, fst_opts) ret end + # Set the default subvolume name + # + # @param [String] Default subvolume name. Only "" and "@" are supported. + # @return [Boolean] True if subvolume was changed; false otherwise. + def default_subvol=(name) + if SUPPORTED_DEFAULT_SUBVOLUME_NAMES.include?(name) + @default_subvol = name + @sint.setDefaultSubvolName(name) unless @sint.nil? + true + else + log.warn "Unsupported default subvolume name='#{name}'. Ignoring." + false + end + end + + # Try to find the default subvolume name in the target system + # + # * Root partition takes precedence + # * Not supported: more than 1 Btrfs filesystems, one using + # a '@' default subvolume and the other using ''. In that case, + # default_subvolume is set to product's default. + # + # @return [String,nil] Default subvolume from the target system + def default_subvol_from_target + Yast.import "Storage" + parts = Storage.GetTargetMap.map { |_k, d| d.fetch("partitions") }.flatten.compact + btrfs_parts = parts.select { |p| p["used_fs"] == :btrfs } + default_subvol_names = btrfs_parts.reduce({}) do |memo, part| + memo[part["mount"]] = btrfs_subvol_name_for(part["mount"]) unless part["mount"].nil? + memo + end + + # Root takes precedence + return default_subvol_names["/"] if default_subvol_names.has_key?("/") + + # If all has the same default subvolume name + found_names = default_subvol_names.values.uniq + return found_names.first if found_names.size == 1 + + # If there are different values, fallback to product's default + default_subvol_from_product + end + + # Default subvol name from product + # + # @return [String] Default subvolume name + def default_subvol_from_product + ProductFeatures.GetStringFeature("partitioning", "btrfs_default_subvolume") + end + + # Read the default subvolume from the filesystem and stores the value + # + # @return [String,nil] Default subvolume from the target system + # @see default_subvol_from_target + def read_default_subvol_from_target + self.default_subvol = default_subvol_from_target + end + + protected + + # Find the default subvolume name + # + # Only "" and "@" are supported. + # + # @param mount [String] Mount point. + # @return ["@", ""] Default subvolume name for the given mount point. + def btrfs_subvol_name_for(mount) + ret = Yast::Execute.on_target("btrfs", "subvol", "list", mount, stdout: :capture) + ret.split("\n").first =~ /.+ @\z/ ? "@" : "" + end + publish :variable => :conv_fs, :type => "map " publish :variable => :possible_root_fs, :type => "const list " publish :function => :system_m_points, :type => "list ()" publish :function => :crypt_m_points, :type => "list ()" publish :variable => :swap_m_points, :type => "const list " publish :variable => :tmp_m_points, :type => "const list " - publish :variable => :default_subvol, :type => "string" publish :variable => :nchars, :type => "string" + publish :function => :default_subvol, :type => "string ()" + publish :function => :default_subvol=, :type => "string (string)" publish :function => :SuggestMPoints, :type => "list ()" publish :function => :SuggestTmpfsMPoints, :type => "list ()" publish :function => :GetGeneralFstabOptions, :type => "list > ()" diff --git a/src/modules/Storage.rb b/src/modules/Storage.rb index c490c3730..55a726187 100644 --- a/src/modules/Storage.rb +++ b/src/modules/Storage.rb @@ -339,10 +339,6 @@ def InitLibstorage(readonly) StorageClients.InstallCallbacks(@sint) - btrfs_default_subvolume = ProductFeatures.GetStringFeature("partitioning", - "btrfs_default_subvolume") - @sint.setDefaultSubvolName(btrfs_default_subvolume) if btrfs_default_subvolume - if Stage.initial @sint.setDetectMountedVolumes(false) @sint.setRootPrefix(Installation.destdir) @@ -375,7 +371,7 @@ def FinishLibstorage def default_subvolume_name() - return @sint.getDefaultSubvolName() + FileSystems.default_subvol end diff --git a/test/filesystems_test.rb b/test/filesystems_test.rb new file mode 100644 index 000000000..2ed72d313 --- /dev/null +++ b/test/filesystems_test.rb @@ -0,0 +1,103 @@ +#!/usr/bin/env rspec + +require_relative "spec_helper" + +Yast.import "FileSystems" +Yast.import "Storage" + +describe Yast::FileSystems do + subject { Yast::FileSystems } + + def btrfs_list_fixture(name) + fixture_name = "btrfs_list_#{name}.out" + File.read(File.join(FIXTURES_PATH, fixture_name)) + end + + let(:default_subvol) { "@" } + let(:libstorage) do + double("libstorage", getDefaultSubvolName: default_subvol, setDefaultSubvolName: default_subvol) + end + + before do + subject.InitSlib(libstorage) + end + + describe "#default_subvol_from_target" do + before do + allow(Yast::Storage).to receive(:GetTargetMap).and_return(target_map) + allow(Yast::ProductFeatures).to receive(:GetStringFeature) + .with("partitioning", "btrfs_default_subvolume").and_return(default_subvol) + end + + context "when root partition uses the default subvolume name (@)" do + let(:target_map) { YAML.load_file(File.join(FIXTURES_PATH, "subvolumes.yml")) } + + before do + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/", anything) + .and_return(btrfs_list_fixture("root")) + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) + .and_return(btrfs_list_fixture("root_no_at")) + end + + it "returns the default subvolume name" do + expect(subject.default_subvol_from_target).to eq(default_subvol) + end + end + + context "when root partitions does not use btrfs" do + let(:target_map) { YAML.load_file(File.join(FIXTURES_PATH, "subvolumes-no-root.yml")) } + + before do + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/", anything) + .and_return(btrfs_list_fixture("root_no_at")) + end + + context "but all btrfs partitions uses the same subvolume name" do + before do + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) + .and_return(btrfs_list_fixture("srv_no_at")) + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/data", anything) + .and_return(btrfs_list_fixture("data_no_at")) + end + + it "returns the used name ('' in this case)" do + expect(subject.default_subvol_from_target).to eq("") + end + end + + context "and btrfs partitions uses different subvolume names" do + before do + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) + .and_return(btrfs_list_fixture("srv")) + allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/data", anything) + .and_return(btrfs_list_fixture("data_no_at")) + end + + it "returns the distribution default" do + expect(subject.default_subvol_from_target).to eq(default_subvol) + end + end + end + end + + describe "#read_default_subvol_from_target" do + it "sets the default_subvol using the value from target" do + subject.default_subvol = "" + expect(subject).to receive(:default_subvol_from_target).and_return("@") + expect { subject.read_default_subvol_from_target }.to change { subject.default_subvol } + .from("").to("@") + end + end + + describe "#default_subvol=" do + it "sets the default_subvol if a valid value is given" do + expect(libstorage).to receive(:setDefaultSubvolName).with("@") + subject.default_subvol = "@" + end + + it "refuses to set default_subvol if an invalid value is given" do + expect(libstorage).to_not receive(:setDefaultSubvolName) + subject.default_subvol = "UNDEFINED" + end + end +end diff --git a/test/fixtures/btrfs_list_data_no_at.out b/test/fixtures/btrfs_list_data_no_at.out new file mode 100644 index 000000000..27370336a --- /dev/null +++ b/test/fixtures/btrfs_list_data_no_at.out @@ -0,0 +1,3 @@ +ID 257 gen 16 top level 5 path shared +ID 258 gen 16 top level 5 path private + diff --git a/test/fixtures/btrfs_list_root.out b/test/fixtures/btrfs_list_root.out new file mode 100644 index 000000000..e34107063 --- /dev/null +++ b/test/fixtures/btrfs_list_root.out @@ -0,0 +1,28 @@ +ID 257 gen 34 top level 5 path @ +ID 258 gen 51 top level 257 path @/.snapshots +ID 259 gen 88 top level 258 path @/.snapshots/1/snapshot +ID 260 gen 44 top level 257 path @/boot/grub2/i386-pc +ID 261 gen 15 top level 257 path @/boot/grub2/x86_64-efi +ID 262 gen 44 top level 257 path @/home +ID 263 gen 51 top level 257 path @/opt +ID 264 gen 50 top level 257 path @/srv +ID 265 gen 88 top level 257 path @/tmp +ID 266 gen 64 top level 257 path @/usr/local +ID 267 gen 38 top level 257 path @/var/crash +ID 268 gen 22 top level 257 path @/var/lib/mailman +ID 269 gen 88 top level 257 path @/var/lib/named +ID 270 gen 24 top level 257 path @/var/lib/pgsql +ID 271 gen 88 top level 257 path @/var/log +ID 272 gen 38 top level 257 path @/var/opt +ID 273 gen 84 top level 257 path @/var/spool +ID 274 gen 51 top level 257 path @/var/tmp +ID 275 gen 30 top level 257 path @/mysubvol +ID 276 gen 47 top level 275 path @/mysubvol/mysubsubvol +ID 277 gen 32 top level 257 path @/myothersubvol +ID 278 gen 47 top level 277 path @/myothersubvol/myothersubsubvol +ID 279 gen 33 top level 257 path @/nocow +ID 280 gen 35 top level 257 path @/myvol +ID 282 gen 40 top level 259 path var/lib/machines +ID 283 gen 48 top level 258 path @/.snapshots/2/snapshot +ID 284 gen 49 top level 258 path @/.snapshots/3/snapshot +ID 285 gen 50 top level 258 path @/.snapshots/4/snapshot diff --git a/test/fixtures/btrfs_list_root_no_at.out b/test/fixtures/btrfs_list_root_no_at.out new file mode 100644 index 000000000..9f539ddca --- /dev/null +++ b/test/fixtures/btrfs_list_root_no_at.out @@ -0,0 +1,27 @@ +ID 257 gen 48 top level 5 path .snapshots +ID 258 gen 92 top level 257 path .snapshots/1/snapshot +ID 259 gen 41 top level 5 path boot/grub2/i386-pc +ID 260 gen 12 top level 5 path boot/grub2/x86_64-efi +ID 261 gen 41 top level 5 path home +ID 262 gen 49 top level 5 path opt +ID 263 gen 47 top level 5 path srv +ID 264 gen 91 top level 5 path tmp +ID 265 gen 61 top level 5 path usr/local +ID 266 gen 35 top level 5 path var/crash +ID 267 gen 19 top level 5 path var/lib/mailman +ID 268 gen 89 top level 5 path var/lib/named +ID 269 gen 21 top level 5 path var/lib/pgsql +ID 270 gen 90 top level 5 path var/log +ID 271 gen 35 top level 5 path var/opt +ID 272 gen 91 top level 5 path var/spool +ID 273 gen 48 top level 5 path var/tmp +ID 274 gen 27 top level 5 path mysubvol +ID 275 gen 44 top level 274 path mysubvol/mysubsubvol +ID 276 gen 29 top level 5 path @/myothersubvol +ID 277 gen 44 top level 276 path @/myothersubvol/myothersubsubvol +ID 278 gen 30 top level 5 path nocow +ID 279 gen 32 top level 5 path myvol +ID 281 gen 37 top level 258 path var/lib/machines +ID 282 gen 45 top level 257 path .snapshots/2/snapshot +ID 283 gen 46 top level 257 path .snapshots/3/snapshot +ID 284 gen 47 top level 257 path .snapshots/4/snapshot diff --git a/test/fixtures/btrfs_list_srv.out b/test/fixtures/btrfs_list_srv.out new file mode 100644 index 000000000..5e21e125a --- /dev/null +++ b/test/fixtures/btrfs_list_srv.out @@ -0,0 +1,5 @@ +ID 257 gen 16 top level 5 path @ +ID 258 gen 16 top level 257 path www +ID 259 gen 16 top level 257 path mirror +ID 260 gen 16 top level 257 path ftp +ID 261 gen 16 top level 257 path tftpboot diff --git a/test/fixtures/btrfs_list_srv_no_at.out b/test/fixtures/btrfs_list_srv_no_at.out new file mode 100644 index 000000000..a84572a69 --- /dev/null +++ b/test/fixtures/btrfs_list_srv_no_at.out @@ -0,0 +1,5 @@ +ID 257 gen 16 top level 5 path www +ID 258 gen 16 top level 5 path mirror +ID 259 gen 16 top level 5 path ftp +ID 260 gen 16 top level 5 path tftpboot + diff --git a/test/fixtures/subvolumes-no-root.yml b/test/fixtures/subvolumes-no-root.yml new file mode 100644 index 000000000..fd889edf6 --- /dev/null +++ b/test/fixtures/subvolumes-no-root.yml @@ -0,0 +1,180 @@ +--- +"/dev/vda": + unique: KSbE.Fxp0d3BezAE + bus: None + device: "/dev/vda" + bios_id: '0x80' + driver: virtio-pci + driver_module: virtio_pci + partitions: + - device: "/dev/vda1" + name: vda1 + used_by_type: :UB_NONE + used_by_device: '' + size_k: 264192 + used_fs: :swap + detected_fs: :swap + mount: swap + mountby: :uuid + fstopt: defaults + uuid: 559e2279-4012-4174-a746-e4664031851d + nr: 1 + fsid: 130 + fstype: Linux swap + region: + - 0 + - 34 + type: :primary + - device: "/dev/vda2" + name: vda2 + used_by_type: :UB_NONE + used_by_device: '' + size_k: 5244928 + used_fs: :ext4 + detected_fs: :ext4 + mount: "/" + mountby: :uuid + fstopt: acl,user_xattr + uuid: 323a8681-4229-4e3f-ac67-c0b70b148ecd + nr: 2 + fsid: 131 + fstype: Linux native + region: + - 33 + - 653 + type: :primary + boot: true + - device: "/dev/vda3" + name: vda3 + used_by: + - type: :UB_BTRFS + device: e71f8bec-08b6-441c-a2d0-b25cc7bc856a + used_by_type: :UB_BTRFS + used_by_device: e71f8bec-08b6-441c-a2d0-b25cc7bc856a + size_k: 2618368 + used_fs: :btrfs + detected_fs: :btrfs + fstopt: defaults + nr: 3 + fsid: 131 + fstype: Linux native + region: + - 685 + - 327 + type: :primary + subvol: + - name: "@/www" + - name: "@/ftp" + - name: "@/mirror" + uuid: e71f8bec-08b6-441c-a2d0-b25cc7bc856a + mount: "/srv" + mountby: :uuid + - device: "/dev/vda4" + name: vda4 + used_by: + - type: :UB_BTRFS + device: aa2af2cd-d43e-44b1-8025-e3d119070d47 + used_by_type: :UB_BTRFS + used_by_device: aa2af2cd-d43e-44b1-8025-e3d119070d47 + size_k: 2357248 + used_fs: :btrfs + detected_fs: :btrfs + fstopt: defaults + nr: 4 + fsid: 131 + fstype: Linux native + region: + - 1011 + - 294 + type: :primary + uuid: aa2af2cd-d43e-44b1-8025-e3d119070d47 + mount: "/data" + mountby: :uuid + size_k: 10485760 + cyl_size: 8225280 + cyl_count: 1305 + sector_size: 512 + label: msdos + name: vda + max_logical: 255 + max_primary: 4 + type: :CT_DISK + transport: :unknown + used_by_type: :UB_NONE + used_by_device: '' + dasd_format: 0 + dasd_type: 0 +"/dev/btrfs": + device: "/dev/btrfs" + name: btrfs + used_by_type: :UB_NONE + used_by_device: '' + type: :CT_BTRFS + partitions: [] +"/dev/tmpfs": + device: "/dev/tmpfs" + name: tmpfs + used_by_type: :UB_NONE + used_by_device: '' + type: :CT_TMPFS + partitions: + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 507800 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/dev/shm" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 507800 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/run" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 507800 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/sys/fs/cgroup" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 101564 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/run/user/483" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 101564 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/run/user/0" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS diff --git a/test/fixtures/subvolumes.yml b/test/fixtures/subvolumes.yml new file mode 100644 index 000000000..308ecdb0c --- /dev/null +++ b/test/fixtures/subvolumes.yml @@ -0,0 +1,185 @@ +--- +"/dev/vda": + unique: KSbE.Fxp0d3BezAE + bus: None + device: "/dev/vda" + bios_id: '0x80' + driver: virtio-pci + driver_module: virtio_pci + partitions: + - device: "/dev/vda1" + name: vda1 + used_by: + - type: :UB_BTRFS + device: 8e6e04a4-758f-4d43-bab8-6b3dca3d31e2 + used_by_type: :UB_BTRFS + used_by_device: 8e6e04a4-758f-4d43-bab8-6b3dca3d31e2 + size_k: 13925376 + used_fs: :btrfs + detected_fs: :btrfs + fstopt: defaults + nr: 2 + fsid: 131 + fstype: Linux native + region: + - 93 + - 1734 + type: :primary + boot: true + subvol: + - name: "@" + - name: "@/.snapshots" + - name: "@/.snapshots/1/snapshot" + - name: "@/home" + - name: "@/var/log" + - name: "@/var/lib/pgsql" + - name: "@/myvol" + nocow: true + - name: "@/.snapshots/1/snapshot/var/lib/machines" + - name: "@/.snapshots/2/snapshot" + - name: "@/.snapshots/3/snapshot" + - name: "@/.snapshots/4/snapshot" + uuid: 8e6e04a4-758f-4d43-bab8-6b3dca3d31e2 + mount: "/" + mountby: :uuid + size_k: 14680064 + cyl_size: 8225280 + cyl_count: 1827 + sector_size: 512 + label: msdos + name: vda + max_logical: 255 + max_primary: 4 + type: :CT_DISK + transport: :unknown + used_by_type: :UB_NONE + used_by_device: '' + dasd_format: 0 + dasd_type: 0 +"/dev/vdb": + unique: KSbE.Fxp0d3BezAE + bus: None + device: "/dev/vdb" + bios_id: '0x80' + driver: virtio-pci + driver_module: virtio_pci + partitions: + - device: "/dev/vdb1" + name: vdb1 + used_by_type: :UB_NONE + used_by_device: '' + size_k: 753664 + used_fs: :swap + detected_fs: :swap + mount: swap + mountby: :uuid + fstopt: defaults + uuid: 3fc06e37-d6b6-4411-baf3-2920cdf19fa4 + nr: 1 + fsid: 130 + fstype: Linux swap + region: + - 0 + - 94 + type: :primary + - device: "/dev/vdb2" + name: vdb2 + used_by: + - type: :UB_BTRFS + device: 862e2cbf-0501-48a1-85a3-142bfe3ab51b + used_by_type: :UB_BTRFS + used_by_device: 862e2cbf-0501-48a1-85a3-142bfe3ab51b + size_k: 13925376 + used_fs: :btrfs + detected_fs: :btrfs + fstopt: defaults + nr: 2 + fsid: 131 + fstype: Linux native + region: + - 93 + - 1734 + type: :primary + boot: true + subvol: + - name: shared + - name: www + uuid: 862e2cbf-0501-48a1-85a3-142bfe3ab51b + mount: "/srv" + mountby: :uuid + size_k: 14680064 + cyl_size: 8225280 + cyl_count: 1827 + sector_size: 512 + label: msdos + name: vdb + max_logical: 255 + max_primary: 4 + type: :CT_DISK + transport: :unknown + used_by_type: :UB_NONE + used_by_device: '' + dasd_format: 0 + dasd_type: 0 +"/dev/btrfs": + device: "/dev/btrfs" + name: btrfs + used_by_type: :UB_NONE + used_by_device: '' + type: :CT_BTRFS + partitions: [] +"/dev/tmpfs": + device: "/dev/tmpfs" + name: tmpfs + used_by_type: :UB_NONE + used_by_device: '' + type: :CT_TMPFS + partitions: + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 233312 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/dev/shm" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 233312 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/run" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 233312 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/sys/fs/cgroup" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS + - device: tmpfs + name: none + used_by_type: :UB_NONE + used_by_device: '' + size_k: 46664 + used_fs: :tmpfs + detected_fs: :tmpfs + mount: "/run/user/0" + mountby: :uuid + ignore_fstab: true + type: :tmpfs + fstype: TMPFS \ No newline at end of file diff --git a/test/storage_test.rb b/test/storage_test.rb index 54de027c2..46ac8305a 100755 --- a/test/storage_test.rb +++ b/test/storage_test.rb @@ -8,14 +8,23 @@ Yast.import "StorageInit" describe "Yast::Storage" do + subject { Yast::Storage } + before do - Yast::Storage.InitLibstorage(false) + subject.InitLibstorage(false) end describe "#SetUserdata" do it "sets given user data for a given device" do # non-zero error for device that does not exist - expect(Yast::Storage.SetUserdata("/dev/ice/does/not/exist", { "/" => "snapshots" })).not_to eq(0) + expect(subject.SetUserdata("/dev/ice/does/not/exist", { "/" => "snapshots" })).not_to eq(0) + end + end + + describe "#default_subvolume_name" do + it "returns the default subvolume name according to FileSystems" do + expect(Yast::FileSystems).to receive(:default_subvol).and_return("SOME-VALUE") + expect(subject.default_subvolume_name).to eq("SOME-VALUE") end end end