Skip to content

Commit ae12bd9

Browse files
committed
test: Add Thread Local Storage test
1 parent 239e1aa commit ae12bd9

5 files changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 2.8.9)
2+
3+
# IncludeOS install location
4+
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
5+
set(ENV{INCLUDEOS_PREFIX} /usr/local)
6+
endif()
7+
include($ENV{INCLUDEOS_PREFIX}/includeos/pre.service.cmake)
8+
project (service)
9+
10+
# Human-readable name of your service
11+
set(SERVICE_NAME "Thread Local Storage test")
12+
13+
# Name of your service binary
14+
set(BINARY "service")
15+
16+
# Source files to be linked with OS library parts to form bootable image
17+
set(SOURCES
18+
service.cpp # ...add more here
19+
)
20+
21+
set(DRIVERS
22+
)
23+
24+
set(PLUGINS
25+
# syslogd # Syslog over UDP
26+
# ...others
27+
)
28+
29+
# include service build script
30+
include($ENV{INCLUDEOS_PREFIX}/includeos/post.service.cmake)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### SMP
2+
3+
```
4+
mkdir build
5+
cd build
6+
cmake ..
7+
make
8+
../run.sh smp_example
9+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This file is a part of the IncludeOS unikernel - www.includeos.org
2+
//
3+
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
4+
// and Alfred Bratterud
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
#include <service>
19+
#include <cassert>
20+
21+
// TBSS area
22+
thread_local int test_int = 0;
23+
thread_local char test_char = 0;
24+
// TDATA area
25+
thread_local char test_array[3] = {1, 2, 3};
26+
thread_local int64_t test_i64 = 0x11ABCDEF22ABCDEF;
27+
28+
void Service::start()
29+
{
30+
int bss_local = 0;
31+
int data_local = 1;
32+
// TBSS area
33+
assert(test_int == 0);
34+
assert(test_char == 0);
35+
// modify TBSS
36+
test_int = 1;
37+
assert(test_int == 1);
38+
// TDATA area
39+
assert(test_array[0] == 1);
40+
assert(test_array[1] == 2);
41+
assert(test_array[2] == 3);
42+
assert(test_i64 == 0x11ABCDEF22ABCDEF);
43+
// modify TDATA area
44+
test_array[0] = 44;
45+
assert(test_array[0] == 44);
46+
assert(test_array[1] == 2);
47+
assert(test_array[2] == 3);
48+
// verify locals
49+
assert(bss_local == 0);
50+
assert(data_local == 1);
51+
printf("SUCCESS\n");
52+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#! /usr/bin/env python
2+
import sys
3+
import os
4+
5+
includeos_src = os.environ.get('INCLUDEOS_SRC',
6+
os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
7+
sys.path.insert(0,includeos_src)
8+
9+
from vmrunner import vmrunner
10+
vm = vmrunner.vms[0];
11+
vm.cmake().boot(20).clean()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mem" : 32
3+
}

0 commit comments

Comments
 (0)