summary refs log tree commit diff stats
path: root/tests/realtimeGC/shared.nim
diff options
context:
space:
mode:
authorJoseph Poirier <jdpoirier@gmail.com>2015-01-06 12:42:36 -0600
committerJoseph Poirier <jdpoirier@gmail.com>2015-01-06 12:42:36 -0600
commite940e7d37b2ffcc24595e99868c40e46c57f74b9 (patch)
tree14b416954fa546e25e20884af99b12b2ff5a2834 /tests/realtimeGC/shared.nim
parent10ba9c4dc152a83b8db8a2987c7a481885be25b0 (diff)
downloadNim-e940e7d37b2ffcc24595e99868c40e46c57f74b9.tar.gz
Test the realtime GC, via long running process in a shared object, without linking nimrtl.dll/so.
Diffstat (limited to 'tests/realtimeGC/shared.nim')
-rw-r--r--tests/realtimeGC/shared.nim60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/realtimeGC/shared.nim b/tests/realtimeGC/shared.nim
new file mode 100644
index 000000000..5da1f1fc2
--- /dev/null
+++ b/tests/realtimeGC/shared.nim
@@ -0,0 +1,60 @@
+discard """
+  cmd: " nim c shared.nim"
+"""
+
+import strutils
+
+var gCounter: uint64
+var gTxStatus: bool
+var gRxStatus: bool
+var gConnectStatus: bool
+var gPttStatus: bool
+var gComm1Status: bool
+var gComm2Status: bool
+
+proc getTxStatus(): string =
+  result = if gTxStatus: "On" else: "Off"
+  gTxStatus = not gTxStatus
+
+proc getRxStatus(): string =
+  result = if gRxStatus: "On" else: "Off"
+  gRxStatus = not gRxStatus
+
+proc getConnectStatus(): string =
+  result = if gConnectStatus: "Yes" else: "No"
+  gConnectStatus = not gConnectStatus
+
+proc getPttStatus(): string =
+  result = if gPttStatus: "PTT: On" else: "PTT: Off"
+  gPttStatus = not gPttStatus
+
+proc getComm1Status(): string =
+  result = if gComm1Status: "On" else: "Off"
+  gComm1Status = not gComm1Status
+
+proc getComm2Status(): string =
+  result = if gComm2Status: "On" else: "Off"
+  gComm2Status = not gComm2Status
+
+proc status() {.exportc: "status", dynlib.} =
+  var tx_status = getTxStatus()
+  var rx_status = getRxStatus()
+  var connected = getConnectStatus()
+  var ptt_status = getPttStatus()
+  var str1: string = "[PilotEdge] Connected: $1  TX: $2  RX: $3" % [connected, tx_status, rx_status]
+  var a = getComm1Status()
+  var b = getComm2Status()
+  var str2: string = "$1  COM1: $2  COM2: $3" % [ptt_status, a, b]
+  echo(str1)
+  echo(str2)
+
+proc count() {.exportc: "count", dynlib.} =
+  var temp: uint64
+  for i in 0..100_000:
+    temp += 1
+  gCounter += 1
+  echo("gCounter: ", gCounter)
+
+proc occupiedMem() {.exportc: "occupiedMem", dynlib.} =
+  echo("Occupied Memmory: ", getOccupiedMem())
+