aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-04-19 23:09:55 +0200
committerLudovic Courtès <ludo@gnu.org>2012-04-19 23:09:55 +0200
commit341c6fdd824bfdaa97ea024cafc741efe9a62060 (patch)
tree9c09c73a9c4fd1b135ccc2f308c55791b19c56a2 /tests
parent1054857d7a69b401f0ca317d28c86cadb285c719 (diff)
downloadguix-341c6fdd824bfdaa97ea024cafc741efe9a62060.tar
guix-341c6fdd824bfdaa97ea024cafc741efe9a62060.tar.gz
Add unit test for derivation parsing and output.
* guix/derivations.scm: Export `read-derivation' and `write-derivation'. * srfi/srfi-64.scm, srfi/srfi-64.upstream.scm: New files, from libchop. * tests/derivations.scm, tests/test.drv: New files.
Diffstat (limited to 'tests')
-rw-r--r--tests/derivations.scm43
-rw-r--r--tests/test.drv1
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
new file mode 100644
index 0000000000..21ec612ee6
--- /dev/null
+++ b/tests/derivations.scm
@@ -0,0 +1,43 @@
+;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
+;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of Guix.
+;;;
+;;; Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (test-derivations)
+ #:use-module (guix derivations)
+ #:use-module (srfi srfi-26)
+ #:use-module (srfi srfi-64)
+ #:use-module (rnrs io ports))
+
+(test-begin "derivations")
+
+(test-assert "parse & export"
+ (let* ((b1 (call-with-input-file "test.drv" get-bytevector-all))
+ (d1 (read-derivation (open-bytevector-input-port b1)))
+ (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>)))
+ (d2 (read-derivation (open-bytevector-input-port b2))))
+ (and (equal? b1 b2)
+ (equal? d1 d2))))
+
+(test-end)
+
+
+(exit (= (test-runner-fail-count (test-runner-current)) 0))
+
+;;; Local Variables:
+;;; eval: (put 'test-assert 'scheme-indent-function 1)
+;;; End:
diff --git a/tests/test.drv b/tests/test.drv
new file mode 100644
index 0000000000..b7b1100d50
--- /dev/null
+++ b/tests/test.drv
@@ -0,0 +1 @@
+Derive([("out","/nix/store/yd0v41r8kj49xcjric62gk47lss9vdyg-hurd-qemu-test-build","","")],[("/nix/store/2fgw8gkxs1k8hfcsvir3q9wnkifdzs2s-bash-4.2-p20.drv",["out"]),("/nix/store/31n2fn5h1gydqs3a9zm5g40d2f886i7g-gnused-4.2.1-i586-pc-gnu.drv",["out"]),("/nix/store/34y69yzzb9a1v1fmixiqfhip9s57pybf-gnugrep-2.10-i586-pc-gnu.drv",["out"]),("/nix/store/6n80yhr7cwip45w8rccyk4bp7g7zlkwq-gnu-global-user-environment.drv",["out"]),("/nix/store/88ymj8xwrkmadyabbc1z96x4prabkhsx-gnumake-3.82-i586-pc-gnu.drv",["out"]),("/nix/store/8c61y42zw57axxixl0wikq6vszjbf9bw-qemu-kvm-0.15.1.drv",["out"]),("/nix/store/8dd520i02y7pkh5ynm7d5jb2lk0m7wzn-mig-20100512-i586-pc-gnu.drv",["out"]),("/nix/store/b4lcngrsl838jg37yn510g888nlf0f1v-gawk-4.0.0-i586-pc-gnu.drv",["out"]),("/nix/store/c4bq6crxpl4y9wd18fkvn81vj93m9wph-findutils-4.4.2-i586-pc-gnu.drv",["out"]),("/nix/store/dgbh8qzl4rr89jsrlsy382z84lmfwsj1-bzip2-1.0.6-i586-pc-gnu.drv",["out"]),("/nix/store/dsplzdbcqwgi9ybb7pfk5z9w6vxbn48h-diffutils-3.2-i586-pc-gnu.drv",["out"]),("/nix/store/f6d7aw8ji6yx715hr91a5bvlbr8hp818-hurd-tarball-0.drv",["out"]),("/nix/store/i81h625d3f6m8v587hx5mq6z6agkg221-gnused-4.2.1.drv",["out"]),("/nix/store/j3kf9392mxcs81vqnn06p5npb8lz4wn8-vm-run.drv",["out"]),("/nix/store/jqv7c1znv48c4w0vk4lmsczjxy0n0hjd-unionfs-20120313-i586-pc-gnu.drv",["out"]),("/nix/store/k34s0wnr7g7bshs61whzrp1vsg8gxzvq-gnutar-1.26-i586-pc-gnu.drv",["out"]),("/nix/store/m56fidnal30ns3zv7bqsxncnmpbqqymq-gnumach-20120303-i586-pc-gnu.drv",["out"]),("/nix/store/phn4yvgccfqyw6izcjbj1kh7lbxkkz4a-bash-4.2-p20-i586-pc-gnu.drv",["out"]),("/nix/store/q86x3m69wq2inrrgsa28d09aapah3nsq-hurd-0.drv",["out"]),("/nix/store/s79ij8nbf48ib60xdwpgf70jhksga31n-stdenv.drv",["out"]),("/nix/store/shsa80axsaxfkdlzpbw5d9ijgjqlmn05-gcc-wrapper-4.6.3-i586-pc-gnu.drv",["out"]),("/nix/store/x55vzgh17b41g1p1c6wf97pjy5mnww1d-gzip-1.4-i586-pc-gnu.drv",["out"]),("/nix/store/y7s99gdw53gf7d7bzhq9snbpdwjqa1ih-smbfs-2012-03-15-i586-pc-gnu.drv",["out"]),("/nix/store/yjq2plg890za7s16mm08x1jyfzj0q5hz-hurd-qemu-image.drv",["out"]),("/nix/store/yjzyf7ngsk816c2al76yprplnxysiwpz-xz-5.0.3-i586-pc-gnu.drv",["out"])],[],"x86_64-linux","/nix/store/xl3xf36l7mzwnl0fr6wxajhzhnm95ygm-bash-4.2-p20/bin/sh",["-e","/nix/store/yrzi7zsymp1a4hrjz75k4fk32kag4pzl-vm-run"],[("QEMU_OPTS","-m 512"),("buildCommand","echo 'Hey, this operating system works like a charm!'\n echo \"Let's see if it can rebuild itself...\"\n\n ( tar xvf \"/nix/store/kck9pjd6y2l1q15384sxywaknfm6b78f-hurd-tarball-0/tarballs/\"*.tar.gz ;\n cd hurd-* ;\n export PATH=\"/nix/store/svz656lvxh0li2pndfgdmgr4i48kbrv8-gawk-4.0.0-i586-pc-gnu/bin:$PATH\" ;\n set -e ;\n ./configure --without-parted --prefix=\"/host/xchg/out\" ;\n make # sequential build\n )\n\n # FIXME: \"make install\" not run because `rm' fails on SMBFS.\n mkdir /host/xchg/out\n\n echo $? > /host/xchg/in-vm-exit\n"),("buildInputs",""),("buildNativeInputs",""),("builder","/nix/store/xl3xf36l7mzwnl0fr6wxajhzhnm95ygm-bash-4.2-p20/bin/sh"),("diskImage","/nix/store/2gqgnw6nmh8ksr5l05cqirw3mdcrnf5p-hurd-qemu-image"),("diskImageBuildInputs","/nix/store/laqpxpssky7v039ga4mvk1c3b36r4gf4-gnumach-20120303-i586-pc-gnu /nix/store/9ypm9rs110msqgb8qykzsxgiab2a6rd7-hurd-0 /nix/store/mkcd3692mkd0llswx3cr9ca6vl12nqzk-gnused-4.2.1-i586-pc-gnu /nix/store/z3zw00xy4ik8b8d6qnaqwbkybr0p2m69-gnugrep-2.10-i586-pc-gnu /nix/store/280rn2c6b6gfg9ynl3qs3zxbgrlkg06d-findutils-4.4.2-i586-pc-gnu /nix/store/wmq0mp74p5ksigq7mpl709l1w8685zqs-diffutils-3.2-i586-pc-gnu /nix/store/b4c3gmg90xyyk13kqwz8hqikjyq1vxyd-bash-4.2-p20-i586-pc-gnu /nix/store/hsxib1jm1ksxnlhxsm00zqhfwln3vp5c-gcc-wrapper-4.6.3-i586-pc-gnu /nix/store/zdjgbwh43yl9kq3j6h5ri3bylinkinzl-gnumake-3.82-i586-pc-gnu /nix/store/xb9llifg0hy342rnj96j70lkbvdmf13h-gnutar-1.26-i586-pc-gnu /nix/store/y8cdvni1hqwmzfwm2ija9v2xb6iqflnx-gzip-1.4-i586-pc-gnu /nix/store/7p7gjd7d605sg1z6m2kvg0zqwylqz4z1-bzip2-1.0.6-i586-pc-gnu /nix/store/0b93rb8x7wh439glp6278xzsq0gf0xcd-xz-5.0.3-i586-pc-gnu /nix/store/6ikghbgf3s71ar1rswk3zczsj03ca3pn-mig-20100512-i586-pc-gnu /nix/store/3jqfrl6f69h65bmx7yzc1prk64993929-smbfs-2012-03-15-i586-pc-gnu /nix/store/nqscl1nn75353qcr9qq5v7w58c24gj12-unionfs-20120313-i586-pc-gnu /nix/store/kp99qz7whrpfc7jy3ycssr3gvrbdz8ra-gnu-global-user-environment /nix/store/laqpxpssky7v039ga4mvk1c3b36r4gf4-gnumach-20120303-i586-pc-gnu /nix/store/9ypm9rs110msqgb8qykzsxgiab2a6rd7-hurd-0 /nix/store/3jqfrl6f69h65bmx7yzc1prk64993929-smbfs-2012-03-15-i586-pc-gnu/hurd/smbfs -s 10.0.2.4 -r smb://10.0.2.4/xchg -u root -p '' /nix/store/3jqfrl6f69h65bmx7yzc1prk64993929-smbfs-2012-03-15-i586-pc-gnu/hurd/smbfs -s 10.0.2.4 -r smb://10.0.2.4/store -u root -p ''"),("memSize","512"),("name","hurd-qemu-test-build"),("out","/nix/store/yd0v41r8kj49xcjric62gk47lss9vdyg-hurd-qemu-test-build"),("postVM","cp -prvd xchg/out \"$out\"\n"),("preVM","diskImage=$(pwd)/disk-image.qcow2\norigImage=\"/nix/store/2gqgnw6nmh8ksr5l05cqirw3mdcrnf5p-hurd-qemu-image\"\nif test -d \"$origImage\"; then origImage=\"$origImage/disk-image.qcow2\"; fi\n/nix/store/sxczq7kv8265b41yr03s4c41pklyq0ih-qemu-kvm-0.15.1/bin/qemu-img create -b \"$origImage\" -f qcow2 $diskImage\n\n# XXX: Until the guest's /nix/store is a unionfs of its actual\n# store and the host's one (i.e., when both unionfs and smbfs\n# implement `io_map', so that ld.so can load binaries off them),\n# rewrite store paths.\necho \"$buildCommand\" | \\\n /nix/store/w5hacn80b04v1f09nkyypc0sd7bhrknb-gnused-4.2.1/bin/sed -r \\\n -e's|/nix/store/([0-9a-z]{32})-([^ ]+)|/host/store/\\1-\\2|g' \\\n > xchg/cmd\n\neval \"$postPreVM\"\n"),("propagatedBuildInputs",""),("propagatedBuildNativeInputs",""),("requiredSystemFeatures","kvm"),("stdenv","/nix/store/7c8asx3yfrg5dg1gzhzyq2236zfgibnm-stdenv"),("system","x86_64-linux")]) \ No newline at end of file