-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from kaistshadow/go-ethereum
Go ethereum
- Loading branch information
Showing
23 changed files
with
839 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## required for independent build | ||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake") # Path for go Module | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../../../../cmake") | ||
|
||
#enable_language(go) | ||
enable_testing() | ||
## required for independent build | ||
include(${CMAKE_MODULE_PATH}/golang.cmake) | ||
include(${CMAKE_MODULE_PATH}/flags.cmake) | ||
|
||
set(SOURCE_FILE test.go) | ||
|
||
|
||
ADD_GO_LIBRARY(gotest ${SOURCE_FILE}) | ||
|
||
|
||
### add test | ||
add_test(NAME regtest-go-test | ||
COMMAND shadow gotest.config.xml | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<shadow> | ||
<!-- our network --> | ||
<topology> | ||
<![CDATA[<?xml version="1.0" encoding="utf-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> | ||
<key attr.name="packetloss" attr.type="double" for="edge" id="d9" /> | ||
<key attr.name="jitter" attr.type="double" for="edge" id="d8" /> | ||
<key attr.name="latency" attr.type="double" for="edge" id="d7" /> | ||
<key attr.name="asn" attr.type="int" for="node" id="d6" /> | ||
<key attr.name="type" attr.type="string" for="node" id="d5" /> | ||
<key attr.name="bandwidthup" attr.type="int" for="node" id="d4" /> | ||
<key attr.name="bandwidthdown" attr.type="int" for="node" id="d3" /> | ||
<key attr.name="geocode" attr.type="string" for="node" id="d2" /> | ||
<key attr.name="ip" attr.type="string" for="node" id="d1" /> | ||
<key attr.name="packetloss" attr.type="double" for="node" id="d0" /> | ||
<graph edgedefault="undirected"> | ||
<node id="poi-1"> | ||
<data key="d0">0.0</data> | ||
<data key="d1">0.0.0.0</data> | ||
<data key="d2">US</data> | ||
<data key="d3">10000020000040</data> | ||
<data key="d4">10000240</data> | ||
<data key="d5">net</data> | ||
</node> | ||
<edge source="poi-1" target="poi-1"> | ||
<data key="d7">50.0</data> | ||
<data key="d8">0.0</data> | ||
<data key="d9">0.0</data> | ||
</edge> | ||
</graph> | ||
</graphml>]]> | ||
</topology> | ||
|
||
<!-- the plug-ins we will be using --> | ||
<plugin id="gotest" path="build/libgotest.so" /> | ||
|
||
<!-- the length of our experiment in seconds 1404101800--> | ||
<kill time="20" /> | ||
<!-- our nodes --> | ||
|
||
<node id="node1"> | ||
<application plugin="gotest" time="13" arguments="" /> | ||
</node> | ||
|
||
</shadow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"C" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
const ( | ||
timeFormat = "2006-01-02T15:04:05-0700" | ||
termTimeFormat = "01-02|15:04:05.000" | ||
floatFormat = 'f' | ||
termMsgJust = 40 | ||
termCtxMaxPadding = 40 | ||
) | ||
|
||
func fmt_printf_formatted_time() { | ||
t := time.Now() | ||
fmt.Printf("%s %s\n", "hello", t.Format(termTimeFormat)) | ||
fmt.Println("test passed") | ||
} | ||
|
||
//export mainGo | ||
func mainGo() { | ||
fmt_printf_formatted_time(); | ||
} | ||
|
||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## required for independent build | ||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake") # Path for go Module | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../../../../cmake") | ||
|
||
#enable_language(go) | ||
enable_testing() | ||
## required for independent build | ||
include(${CMAKE_MODULE_PATH}/golang.cmake) | ||
include(${CMAKE_MODULE_PATH}/flags.cmake) | ||
|
||
set(SOURCE_FILE gotest_ioutils.go) | ||
|
||
|
||
ADD_GO_LIBRARY(gotest_ioutils ${SOURCE_FILE}) | ||
|
||
|
||
### add test | ||
add_test(NAME regtest-go-test | ||
COMMAND shadow gotest_ioutils.config.xml | ||
WORKING_DIRECTORY "..") | ||
|
44 changes: 44 additions & 0 deletions
44
tests/regtest/shadow-golang/gotest_ioutils/gotest_ioutils.config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<shadow> | ||
<!-- our network --> | ||
<topology> | ||
<![CDATA[<?xml version="1.0" encoding="utf-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> | ||
<key attr.name="packetloss" attr.type="double" for="edge" id="d9" /> | ||
<key attr.name="jitter" attr.type="double" for="edge" id="d8" /> | ||
<key attr.name="latency" attr.type="double" for="edge" id="d7" /> | ||
<key attr.name="asn" attr.type="int" for="node" id="d6" /> | ||
<key attr.name="type" attr.type="string" for="node" id="d5" /> | ||
<key attr.name="bandwidthup" attr.type="int" for="node" id="d4" /> | ||
<key attr.name="bandwidthdown" attr.type="int" for="node" id="d3" /> | ||
<key attr.name="geocode" attr.type="string" for="node" id="d2" /> | ||
<key attr.name="ip" attr.type="string" for="node" id="d1" /> | ||
<key attr.name="packetloss" attr.type="double" for="node" id="d0" /> | ||
<graph edgedefault="undirected"> | ||
<node id="poi-1"> | ||
<data key="d0">0.0</data> | ||
<data key="d1">0.0.0.0</data> | ||
<data key="d2">US</data> | ||
<data key="d3">10000020000040</data> | ||
<data key="d4">10000240</data> | ||
<data key="d5">net</data> | ||
</node> | ||
<edge source="poi-1" target="poi-1"> | ||
<data key="d7">50.0</data> | ||
<data key="d8">0.0</data> | ||
<data key="d9">0.0</data> | ||
</edge> | ||
</graph> | ||
</graphml>]]> | ||
</topology> | ||
|
||
<!-- the plug-ins we will be using --> | ||
<plugin id="gotest_ioutils" path="build/libgotest_ioutils.so" /> | ||
|
||
<!-- the length of our experiment in seconds 1404101800--> | ||
<kill time="20" /> | ||
<!-- our nodes --> | ||
|
||
<node id="node1"> | ||
<application plugin="gotest_ioutils" time="13" arguments="" /> | ||
</node> | ||
|
||
</shadow> |
63 changes: 63 additions & 0 deletions
63
tests/regtest/shadow-golang/gotest_ioutils/gotest_ioutils.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package main | ||
|
||
import ( | ||
"C" | ||
"bufio" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
func check(e error) { | ||
if e != nil { | ||
panic(e) | ||
} | ||
} | ||
|
||
func test() { | ||
dat, err := ioutil.ReadFile("/proc/meminfo") | ||
check(err) | ||
fmt.Print(string(dat)) | ||
|
||
f, err := os.Open("/proc/meminfo") | ||
check(err) | ||
|
||
b1 := make([]byte, 5) | ||
n1, err := f.Read(b1) | ||
check(err) | ||
fmt.Printf("%d bytes: %s\n", n1, string(b1[:n1])) | ||
|
||
o2, err := f.Seek(6, 0) | ||
check(err) | ||
b2 := make([]byte, 2) | ||
n2, err := f.Read(b2) | ||
check(err) | ||
fmt.Printf("%d bytes @ %d: ", n2, o2) | ||
fmt.Printf("%v\n", string(b2[:n2])) | ||
|
||
o3, err := f.Seek(6, 0) | ||
check(err) | ||
b3 := make([]byte, 2) | ||
n3, err := io.ReadAtLeast(f, b3, 2) | ||
check(err) | ||
fmt.Printf("%d bytes @ %d: %s\n", n3, o3, string(b3)) | ||
|
||
_, err = f.Seek(0, 0) | ||
check(err) | ||
|
||
r4 := bufio.NewReader(f) | ||
b4, err := r4.Peek(5) | ||
check(err) | ||
fmt.Printf("5 bytes: %s\n", string(b4)) | ||
|
||
f.Close() | ||
} | ||
|
||
//export mainGo | ||
func mainGo() { | ||
test() | ||
} | ||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## required for independent build | ||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake") # Path for go Module | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../../../../cmake") | ||
|
||
#enable_language(go) | ||
enable_testing() | ||
## required for independent build | ||
include(${CMAKE_MODULE_PATH}/golang.cmake) | ||
include(${CMAKE_MODULE_PATH}/flags.cmake) | ||
|
||
set(SOURCE_FILE gotest_mmap.go) | ||
|
||
|
||
ADD_GO_LIBRARY(gotest_mmap ${SOURCE_FILE}) | ||
|
||
|
||
### add test | ||
add_test(NAME regtest-go-test | ||
COMMAND shadow gotest_mmap.config.xml | ||
WORKING_DIRECTORY "..") | ||
|
44 changes: 44 additions & 0 deletions
44
tests/regtest/shadow-golang/gotest_mmap/gotest_mmap.config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<shadow> | ||
<!-- our network --> | ||
<topology> | ||
<![CDATA[<?xml version="1.0" encoding="utf-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> | ||
<key attr.name="packetloss" attr.type="double" for="edge" id="d9" /> | ||
<key attr.name="jitter" attr.type="double" for="edge" id="d8" /> | ||
<key attr.name="latency" attr.type="double" for="edge" id="d7" /> | ||
<key attr.name="asn" attr.type="int" for="node" id="d6" /> | ||
<key attr.name="type" attr.type="string" for="node" id="d5" /> | ||
<key attr.name="bandwidthup" attr.type="int" for="node" id="d4" /> | ||
<key attr.name="bandwidthdown" attr.type="int" for="node" id="d3" /> | ||
<key attr.name="geocode" attr.type="string" for="node" id="d2" /> | ||
<key attr.name="ip" attr.type="string" for="node" id="d1" /> | ||
<key attr.name="packetloss" attr.type="double" for="node" id="d0" /> | ||
<graph edgedefault="undirected"> | ||
<node id="poi-1"> | ||
<data key="d0">0.0</data> | ||
<data key="d1">0.0.0.0</data> | ||
<data key="d2">US</data> | ||
<data key="d3">10000020000040</data> | ||
<data key="d4">10000240</data> | ||
<data key="d5">net</data> | ||
</node> | ||
<edge source="poi-1" target="poi-1"> | ||
<data key="d7">50.0</data> | ||
<data key="d8">0.0</data> | ||
<data key="d9">0.0</data> | ||
</edge> | ||
</graph> | ||
</graphml>]]> | ||
</topology> | ||
|
||
<!-- the plug-ins we will be using --> | ||
<plugin id="gotest_mmap" path="build/libgotest_mmap.so" /> | ||
|
||
<!-- the length of our experiment in seconds 1404101800--> | ||
<kill time="20" /> | ||
<!-- our nodes --> | ||
|
||
<node id="node1"> | ||
<application plugin="gotest_mmap" time="13" arguments="" /> | ||
</node> | ||
|
||
</shadow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// https://golang.org/src/syscall/mmap_unix_test.go | ||
|
||
package main | ||
|
||
import ( | ||
"C" | ||
"syscall" | ||
"fmt" | ||
) | ||
|
||
func TestMmap() { | ||
b, err := syscall.Mmap(-1, 0, 4096, syscall.PROT_NONE, syscall.MAP_ANON|syscall.MAP_PRIVATE) | ||
if err != nil { | ||
fmt.Printf("well\n") | ||
} | ||
b[0] = 'x' | ||
if err := syscall.Munmap(b); err != nil { | ||
fmt.Printf("well\n") | ||
} | ||
|
||
} | ||
|
||
//export mainGo | ||
func mainGo() { | ||
TestMmap() | ||
} | ||
func main() { | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
tests/regtest/shadow-golang/gotest_syscalls/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## required for independent build | ||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake") # Path for go Module | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "../../../../cmake") | ||
|
||
#enable_language(go) | ||
enable_testing() | ||
## required for independent build | ||
include(${CMAKE_MODULE_PATH}/golang.cmake) | ||
include(${CMAKE_MODULE_PATH}/flags.cmake) | ||
|
||
set(SOURCE_FILE gotest_syscalls.go) | ||
|
||
|
||
ADD_GO_LIBRARY(gotest_syscalls ${SOURCE_FILE}) | ||
|
||
|
||
### add test | ||
add_test(NAME regtest-go-test | ||
COMMAND shadow gotest_syscalls.config.xml | ||
WORKING_DIRECTORY "..") | ||
|
Empty file.
Oops, something went wrong.