コード例 #1
0
ファイル: basic.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     baseline = "sample-baseline"
     build.loads("""
         playbook:
             - baseline: %s
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
     """ % baseline)
     spec = build.parse()
     if spec["baseline"] != baseline:
         self.fail("selected baseline is '%s' but expected '%s'!" %
                   (spec["baseline"], baseline))
コード例 #2
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
                   flags:
                       - boot
     """)
     build.loads("""
         image:
             partitions:
                 - label: rootfs
                   flags:
                       - boot
                       - primary
     """)
     spec = build.parse()
     parts = spec["image"]["partitions"]
     if len(parts) != 1 or parts[0]["label"] != "rootfs":
         self.fail("expected 1 partition: 'rootfs' (got %s)" % parts)
     part = parts[0]
     if len(part["flags"]) != 2:
         self.fail("expected 2 partition flags: got %s" % part["flags"])
コード例 #3
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
     """)
     build.loads("""
         image:
             partitions:
                 - label: rootfs
                   flags:
                       - boot
                       - primary
                   size: 256MiB
     """)
     spec = build.parse()
     parts = spec["image"]["partitions"]
     if len(parts) != 1 or parts[0]["label"] != "rootfs":
         self.fail("expected 1 partition: 'rootfs' (got %s)" % parts)
     part = parts[0]
     if len(part["flags"]) != 2:
         self.fail("expected 2 partition flags: got %s" % part["flags"])
     if part["size"] != 256 * 1024 * 1024:
         self.fail("expected size of 256MiB: got %s" % part["size"])
     if part["where"] != "/":
         self.fail("expected 'where' to be '/': got %s" % part["where"])
コード例 #4
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
     """)
     build.loads("""
         image:
             partitions:
                 - label: data
                   priority: 800
                   where: /var
                 - label: boot
                   priority: 100
                   where: /boot
     """)
     spec = build.parse()
     parts = spec["image"]["partitions"]
     if len(parts) != 3 or parts[0]["label"] != "boot" or parts[1][
             "label"] != "rootfs" or parts[2]["label"] != "data":
         self.fail(
             "expected 3 partitions: 'boot', 'rootfs' and 'data' (got %s)" %
             parts)
コード例 #5
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: main
                   group: main
                   size: 1GiB
                   flags:
                       - lvm
             volumes:
                 - label: rootfs
                   group: main
                   size: 750MiB
                   where: /
     """)
     build.loads("""
         image:
             volumes:
                 - label: rootfs
                   size: 500MiB
     """)
     spec = build.parse()
     vols = spec["image"]["volumes"]
     if len(vols) != 1 or vols[0]["label"] != "rootfs":
         self.fail("expected 1 volume: 'rootfs' (got %s)" % vols)
     vol = vols[0]
     if vol["size"] != 750 * 1024 * 1024:
         self.fail("expected size of 750MiB: got %s" % vol["size"])
コード例 #6
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: main
                   group: main
                   size: 1GiB
                   flags:
                       - lvm
             volumes:
                 - label: rootfs
                   group: main
                   where: /
     """)
     build.loads("""
         image:
             volumes:
                 - label: data
                   group: main
                   priority: 800
                   where: /var
                 - label: boot
                   group: main
                   priority: 100
                   where: /boot
     """)
     spec = build.parse()
     vols = spec["image"]["volumes"]
     if len(vols) != 3 or vols[0]["label"] != "boot" or vols[1][
             "label"] != "rootfs" or vols[2]["label"] != "data":
         self.fail(
             "expected 3 volumes: 'boot', 'rootfs' and 'data' (got %s)" %
             vols)
コード例 #7
0
def main():
    argv = sys.argv[1:]

    if len(argv) == 0:
        print("%s: error: missing command argument!" % sys.argv[0])
        sys.exit(1)

    cmd = argv[0]
    if cmd == "build":
        BuildCmd().main(argv[1:])
    else:
        print("%s: unknown command '%s'!" % (sys.argv[0], cmd))
        sys.exit(1)
コード例 #8
0
ファイル: basic.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     baseline = "sample-baseline"
     build.loads("""
         playbook:
             - baseline: least-prio-baseline
               priority: 900
             - baseline: %s
               priority: 100
             - baseline: default-prio-baseline
             - baseline: medium-prio-baseline
               priority: 600
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
     """ % baseline)
     spec = build.parse()
     if spec["baseline"] != baseline:
         self.fail("selected baseline is '%s' but expected '%s'!" %
                   (spec["baseline"], baseline))
コード例 #9
0
ファイル: basic.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             image:
                 filename: simple-test.img
                 partitions:
                     - label: rootfs
                       where: /
         """)
         build.parse()
     except:
         self.fail("failed to parse a valid minimal spec!")
コード例 #10
0
ファイル: partitions.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             image:
                 filename: simple-test.img
                 table: msdos
                 partitions:
                     - label: rootfs
                       where: /
         """)
         build.parse()
     except:
         self.fail("parsing of a specification with a 'msdos' partition table failed!")
コード例 #11
0
ファイル: merge.py プロジェクト: chombourger/seine
 def test(self):
     build = BuildCmd()
     build.loads("""
         image:
             filename: simple-test.img
             partitions:
                 - label: rootfs
                   where: /
     """)
     build.loads("""
         image:
             partitions:
                 - label: data
                   where: /var
     """)
     spec = build.parse()
     parts = spec["image"]["partitions"]
     if len(parts) != 2 or parts[0]["label"] != "rootfs" or parts[1][
             "label"] != "data":
         self.fail("expected 2 partitions: 'rootfs' and 'data' (got %s)" %
                   parts)
コード例 #12
0
ファイル: partitions.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             image:
                 filename: simple-test.img
                 partitions:
                       where: /
         """)
         build.parse()
         self.fail("parsing should have failed (missing partition label)!")
     except ValueError as e:
         if str(e) != "one of the partitions does not have a 'label' defined!":
             self.fail("parsing did not return the error we expected!")
     except avocado.core.exceptions.TestFail:
         raise
     except Exception as e:
         self.fail("parsing caused an unknown error: %s" % str(type(e)))
コード例 #13
0
ファイル: basic.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             image:
                 partitions:
                     - label: rootfs
                       where: /
         """)
         build.parse()
         self.fail(
             "parsing succeeded when it should have failed (missing 'filename' in 'image')!"
         )
     except ValueError as e:
         if str(e) != "output 'filename' not specified in 'image' section!":
             self.fail("parsing did not return the error we expected!")
     except avocado.core.exceptions.TestFail:
         raise
     except Exception as e:
         self.fail("parsing caused an unknown error: %s" % str(type(e)))
コード例 #14
0
ファイル: partitions.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             image:
                 filename: simple-test.img
                 table: unsupported-partition-table
                 partitions:
                     - label: rootfs
                       where: /
         """)
         build.parse()
         self.fail("parsing should have failed (invalid partition table)!")
     except ValueError as e:
         if str(e) != "'unsupported-partition-table' is not a supported partition table!":
             self.fail("parsing did not return the error we expected!")
     except avocado.core.exceptions.TestFail:
         raise
     except Exception as e:
         self.fail("parsing caused an unknown error: %s" % str(type(e)))
コード例 #15
0
ファイル: basic.py プロジェクト: chombourger/seine
 def test(self):
     try:
         build = BuildCmd()
         build.loads("""
             playbook: impossible
             image:
                 filename: simple-test.img
                 partitions:
                     - label: rootfs
                       where: /
         """)
         build.parse()
         self.fail(
             "parsing succeeded when it should have failed ('playbook' is not a list)!"
         )
     except ValueError as e:
         if str(e) != "'playbook' shall be a list of Ansible playbooks!":
             self.fail("parsing did not return the error we expected!")
     except avocado.core.exceptions.TestFail:
         raise
     except Exception as e:
         self.fail("parsing caused an unknown error: %s" % str(type(e)))