Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit test infrastructure #24

Merged
merged 54 commits into from
May 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f22a6c6
Reformatted + place the packages we install on one line per package.
perlun Apr 21, 2015
4492053
Added cmake.
perlun Apr 21, 2015
cc80ff3
Moved stuff related to setting up the shell environment to the end.
perlun Apr 21, 2015
c853a71
Added a section for downloading and building cmocka.
perlun Apr 21, 2015
0fa7802
Removed no-long-relevant FIXME.
perlun Apr 21, 2015
68570f9
Servers, not libraries.
perlun Apr 21, 2015
135ca42
Allow CFLAGS to be an array.
perlun Apr 21, 2015
eb6060b
We need gcc-multilib, to be able to compile i386 stuff.
perlun Apr 21, 2015
a8f1f84
Added WIP test for trying out cmocka on a simple use case.
perlun Apr 21, 2015
b485a1a
Need to compile cmocka in 32-bit mode.
perlun Apr 21, 2015
3e443b7
We need /usr/local/lib in the library path, since that's where cmocka…
perlun Apr 22, 2015
c024786
Renamed the main file, to avoid having too many files with similar na…
perlun Apr 22, 2015
91e2258
We should compile the unit tests also by default.
perlun Apr 22, 2015
cd8d6f5
Added test running to our Rakefiles.
perlun Apr 22, 2015
46905ca
Moved the cmocka installation to a shell script, so we can run it fro…
perlun Apr 22, 2015
29a5b93
Let's give this a try now and see if it works.
perlun Apr 22, 2015
3b8286f
We don't ned g++, but we do need gcc-multilib.
perlun Apr 22, 2015
90817c5
Yes, you were right CMake. We do need administrative privileges. :)
perlun Apr 22, 2015
3c27cb5
Let's try to see if ia32-libs gives us a working libgcc, so Travis bu…
perlun Apr 23, 2015
19470d7
I don't like Ubuntu. Let's try to use wheezy straight away instead.
perlun Apr 23, 2015
a88c009
Let's try another combo and see if that works better...
perlun Apr 23, 2015
3865ae2
I am lazy, so let's go with force-yes.
perlun Apr 23, 2015
ad3e7e2
Let's try and KISS.
perlun Apr 23, 2015
e5c941a
Let's try with the default (4.6) gcc and see if it works?
perlun Apr 23, 2015
852ebbf
Cool, it compiled! Let's see if it runs the tests also?
perlun Apr 23, 2015
609a9cd
We need /usr/local/lib in the lib path.
perlun Apr 23, 2015
17a392f
We need to set the return value in line with whether the call failed …
perlun Apr 24, 2015
55f39e8
Should never have been committed.
perlun Apr 24, 2015
cdd509e
Updated ignore list.
perlun Apr 24, 2015
529f5c8
I want 'rake tests' to run all tests.
perlun Apr 24, 2015
2961432
rake tests, not rake run_tests.
perlun Apr 24, 2015
9e5f96d
Need to set up to use gcc always, not only for building the tests.
perlun Apr 24, 2015
1990bd7
Let's free up the name 'main' so we don't mess things up for our unit…
perlun Apr 30, 2015
3457e72
Whitespace changes.
perlun Apr 30, 2015
b6d195f
Be Rubocop compliant.
perlun Apr 30, 2015
4cd44fa
Made the tests linkable.
perlun Apr 30, 2015
0667a99
Rake updates for the storm_tests.
perlun Apr 30, 2015
e7c0feb
We need to be able to access the storm include files.
perlun Apr 30, 2015
6f23360
More whitespace-ish changes.
perlun Apr 30, 2015
453502c
Let's not be so picky now.
perlun Apr 30, 2015
838a84a
Updated copyright.
perlun Apr 30, 2015
f391256
Updated copyrights.
perlun Apr 30, 2015
3e2b62c
Don't be so picky about unused parameters.
perlun Apr 30, 2015
5729459
I changed my mind. Having this as a multiline string is better after …
perlun Apr 30, 2015
3926ea2
We want to be able to override certain methods, for testing purposes.
perlun Apr 30, 2015
5eb699c
Added unfinished tests for memory_global_allocate and memory_global_d…
perlun Apr 30, 2015
379a408
Added test.
perlun May 1, 2015
7c02b33
Disabled the tests for now, since they are hard to get working right.
perlun May 1, 2015
dcdcc7f
Reformatted and updated copyright.
perlun May 1, 2015
9ea92b9
A header file should include its logical dependencies, whenever feasi…
perlun May 2, 2015
751bf0a
Added a ouple of string tests as well.
perlun May 2, 2015
90eea90
Added more string unit tests.
perlun May 2, 2015
7dcbf67
Handle cases where the tests fail to run in a proper way.
perlun May 2, 2015
f1a6c00
Need to run ldconfig also.
perlun May 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
.vagrant
floppy.img

*.dep
*.o
*.a
floppy.img

storm/current-arch
storm/ia32/storm
storm/include/storm/current-arch
.vagrant
storm_tests/ia32/ia32_tests

servers/system/boot/boot
servers/system/console/console
Expand Down
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
env: CC=gcc
before_script:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update
- sudo apt-get install g++-4.7 nasm
- sudo apt-get install gcc-multilib nasm
- ./install_cmocka.sh
script:
- rake
- rake tests
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ task :storm do |folder|
sh "cd #{folder} && #{RAKE_COMMAND}"
end

desc "Compiles the unit tests for the 'storm' kernel."
task :build_storm_tests => :storm do
sh "cd storm_tests && #{RAKE_COMMAND}"
end

desc 'Runs the unit tests'
task :tests => [:build_storm_tests] do
sh "cd storm_tests && #{RAKE_COMMAND} tests"
end

task :libraries => [ :storm ] do |folder|
sh "cd #{folder} && #{RAKE_COMMAND}"
end
Expand Down
30 changes: 21 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
Vagrant.configure(2) do |config|
config.vm.box = 'chef/debian-7.8'
config.vm.provision 'shell', inline: <<-SHELL
set -e
sudo apt-get update
sudo apt-get install -y git mtools nasm rake astyle qemu
echo 'cd /vagrant' >> /home/vagrant/.bashrc
cd /vagrant && bzip2 -dc misc/grub.img.bz2 > floppy.img
echo 'drive a: file="/vagrant/floppy.img" 1.44m mformat_only' > /etc/mtools.conf
echo '-U' > /home/vagrant/.astylerc
echo '-H' >> /home/vagrant/.astylerc
echo '-S' >> /home/vagrant/.astylerc
set -e
sudo apt-get update
sudo apt-get install -y \
astyle \
cmake \
gcc-multilib \
git \
mtools \
nasm \
qemu \
rake

cd /vagrant
./install_cmocka.sh

cd /vagrant && bzip2 -dc misc/grub.img.bz2 > floppy.img
echo 'drive a: file="/vagrant/floppy.img" 1.44m mformat_only' > /etc/mtools.conf
echo 'cd /vagrant' >> /home/vagrant/.bashrc
echo '-U' > /home/vagrant/.astylerc
echo '-H' >> /home/vagrant/.astylerc
echo '-S' >> /home/vagrant/.astylerc
SHELL
end
14 changes: 14 additions & 0 deletions install_cmocka.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

cd /tmp
rm -rf cmocka*
wget https://cmocka.org/files/1.0/cmocka-1.0.1.tar.xz
tar xf cmocka-1.0.1.tar.xz
cd cmocka-1.0.1
mkdir build
cd build
cmake -DCMAKE_C_FLAGS=-m32 ..
make
sudo make install
sudo sh -c 'echo /usr/local/lib >> /etc/ld.so.conf'
sudo /sbin/ldconfig
7 changes: 6 additions & 1 deletion rakelib/common_rules.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rule '.o' => [ '.c' ] do |t|
begin
print((t.source + ' ').cyan)
command = "#{CC} -o #{t.name} #{CFLAGS} #{INCLUDES.join(' ')} -c #{t.source}"
command = "#{CC} -o #{t.name} #{cflags} #{INCLUDES.join(' ')} -c #{t.source}"
sh command
rescue
puts "Error compiling #{t.source}. Full command line was: #{command}"
Expand Down Expand Up @@ -41,3 +41,8 @@ rule '.o' => [ '.asm' ] do |t|
raise
end
end

def cflags
flags = CFLAGS.join(' ') if CFLAGS.respond_to?(:join)
flags ||= CFLAGS
end
3 changes: 0 additions & 3 deletions rakelib/common_settings.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
verbose false

# FIXME: Should consider supporting a toplevel Rakefile.local or something where you can define this, so you don't have to
# modify a version-controlled file.

UNAME = `uname`.strip

case UNAME
Expand Down
2 changes: 1 addition & 1 deletion servers/servers.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Common settings and Rake rules for all libraries.
# Common settings and Rake rules for all servers.

Rake.application.options.rakelib = ["#{File.dirname(__FILE__)}/../rakelib"] if Rake.application.options.rakelib.first == 'rakelib'

Expand Down
2 changes: 1 addition & 1 deletion storm/generic/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OBJECTS = %w(
# TODO: Would like to use STORM_GENERIC_LIB, but for whatever reason it is not available in this context.
OUTPUT = 'libstorm_generic.a'

task :default => [ :banner, OUTPUT ] do
task :default => [:banner, OUTPUT] do
puts
end

Expand Down
25 changes: 13 additions & 12 deletions storm/ia32/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,8 @@ u32 multiboot_header[] __attribute__ ((section(".init.pre"), unused)) =

// FIXME: Put those in another file. We should have a better system for local include files...
void _start (void) INIT_CODE;
extern int main (int arguments, char *argument[]);

// This is the kernel. :)
static void INIT_CODE kernel_entry (void) NORETURN;
static void INIT_CODE kernel_entry(void)
{
multiboot_init();

main(((u8 *) arguments_kernel)[0], (char **) &arguments_kernel[4]);

// This code should never really get called.
idle();
}
extern int kernel_main (int arguments, char *argument[]);

// This is the kernel entry point.
// FIXME: Use memory_copy and memory_set instead of inline assembler. The current way is very hard to optomize for e.g.
Expand Down Expand Up @@ -164,3 +153,15 @@ void _start(void)
: "n" (SELECTOR_KERNEL_CODE),
"p" (&kernel_entry));
}

// When this gets called, the new (temporary) GDT has been set up and the segment selectors have been initialized with
// their new values.
static void INIT_CODE kernel_entry(void)
{
multiboot_init();

kernel_main(((u8 *) arguments_kernel)[0], (char **) &arguments_kernel[4]);

// This code should never really get called.
idle();
}
4 changes: 2 additions & 2 deletions storm/ia32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ static void INIT_CODE parse_kernel_arguments(unsigned int arguments, char *argum
}

// This is where the fun begins. Oh, yeah, we're going to Disneyland... blah blah. Terminator 2 RULEZ!
return_type main(int arguments, char *argument[]) INIT_CODE;
return_type kernel_main(int arguments, char *argument[]) INIT_CODE;

return_type main(int arguments, char *argument[])
return_type kernel_main(int arguments, char *argument[])
{
int servers_started = 0;

Expand Down
Loading