Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from hypriot/add-tests
Browse files Browse the repository at this point in the history
Add serverspec tests for rpi-raw image
  • Loading branch information
StefanScherer committed Jan 30, 2016
2 parents c0e57a4 + 008810c commit b4a4c1e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.img
*.img.zip
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
rm -rf /var/lib/apt/lists/*

RUN gem update --system && \
gem install --no-document serverspec && \
gem install --no-document pry-byebug
gem install --no-document serverspec
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
docker build -t image-builder-raw .

rpi-raw-image: build
docker run --rm --privileged -v $(shell pwd):/workspace image-builder-raw /workspace/build/rpi.sh
docker run --rm --privileged -v $(shell pwd):/workspace image-builder-raw /workspace/builder/rpi/build.sh

shell: build
docker run -ti --privileged -v $(shell pwd):/workspace image-builder-raw bash
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Raw Image Builder [![Build Status](https://travis-ci.org/hypriot/image-builder-raw.svg?branch=v0.0.5)](https://travis-ci.org/hypriot/image-builder-raw)
# Raw Image Builder
[![Join the chat at https://gitter.im/hypriot/talk](https://badges.gitter.im/hypriot/talk.svg)](https://gitter.im/hypriot/talk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/hypriot/image-builder-raw.svg)](https://travis-ci.org/hypriot/image-builder-raw)

This repo creates a number of blank images for a couple of ARM dev boards.
These images have the necessary partitions, sizes and filesystem - but not actual files.

Currently there is the following image:

* `rpi-raw-image` with two partitions (FAT + EXT4) for the Raspberry Pi

## Contributing

You can contribute to this repo by forking it and sending us pull requests. Feedback is always welcome!

You can build the root filesystem locally with Docker.

```bash
make rpi-raw-image
```


## License

MIT - see the [LICENSE](./LICENSE) file for details.
8 changes: 6 additions & 2 deletions build/rpi.sh → builder/rpi/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e
set -x
#!/bin/bash
set -ex
# This script should be run only inside of a Docker container
if [ ! -f /.dockerinit ]; then
echo "ERROR: script works only in a Docker container!"
Expand Down Expand Up @@ -56,3 +56,7 @@ umask 0000

# compress image
zip ${BUILD_RESULT_PATH}/${IMAGE_PATH}.zip ${IMAGE_PATH}

fdisk -l /rpi-raw.img
# test raw image that we have built
rspec --format documentation --color ${BUILD_RESULT_PATH}/builder/rpi/test
28 changes: 28 additions & 0 deletions builder/rpi/test/image_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'serverspec'
set :backend, :exec

describe "Raw Image" do
let(:image_path) { return '/rpi-raw.img' }

it "exists" do
image_file = file(image_path)
expect(image_file).to exist
end

context "Partition table" do
let(:stdout) { command("fdisk -l #{image_path} | grep '^/rpi-raw'").stdout }

it "has 2 partitions" do
partitions = stdout.split(/\r?\n/)
expect(partitions.size).to be 2
end

it "has a boot-partition with a sda1 W95 FAT32 filesystem" do
expect(stdout).to contain('^.*\.img1 .*W95 FAT32 \(LBA\)$')
end

it "has a root-partition with a sda2 Linux filesystem" do
expect(stdout).to contain('^.*\.img2 .*Linux$')
end
end
end
5 changes: 0 additions & 5 deletions test/rpi_spec.rb

This file was deleted.

0 comments on commit b4a4c1e

Please sign in to comment.