This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added pthread sample testcase * Ada threading testapp * ada testcases * pthread testcase * update pthread worker testcase * update the licence header
- Loading branch information
1 parent
63033f4
commit b6d18e1
Showing
47 changed files
with
416 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
-Wall; |
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 @@ | ||
-Wall; |
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 @@ | ||
-Wall; |
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 @@ | ||
-Wall;-Werror |
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 @@ | ||
-Wall;-Werror |
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 @@ | ||
A simple Ada threading application |
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 @@ | ||
A thread implementation in Ada |
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 @@ | ||
A simple producer/consumer implementation in Ada |
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 @@ | ||
A simple pthread support test |
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 @@ | ||
A simple producer/consumer implementation in pthread. |
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 @@ | ||
1000000 |
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 @@ | ||
1000000 |
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 @@ | ||
-lm -lgnat -lpthread -lgnarl |
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 @@ | ||
-lm -lgnat -lpthread -lgnarl |
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 @@ | ||
-lm -lgnat -lpthread -lgnarl |
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 @@ | ||
-lpthread |
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 @@ | ||
-lpthread |
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 @@ | ||
111112222200000 |
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 @@ | ||
Test Passed 2001000 |
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 @@ | ||
Executed 1000000 iterations |
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,7 @@ | ||
Create threads | ||
Wait for the threads to complete, and release their resources | ||
foo(), tls data=1 4 | ||
bar(), tls data=1 4 | ||
foo(), tls data=0 2 | ||
bar(), tls data=0 2 | ||
Main completed |
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 @@ | ||
Executed 1000000 iterations |
41 changes: 41 additions & 0 deletions
41
tests/test_suite_generator/src/linux/ada_thread1/ada_thread.adb
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,41 @@ | ||
-- | ||
-- Copyright (c) 2017 Trail of Bits, Inc. | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
|
||
with Ada.Text_IO;use Ada.Text_IO; | ||
|
||
procedure Ada_Thread is | ||
task Write_Zeros; | ||
task Write_Ones; | ||
|
||
task body Write_Zeros is | ||
begin | ||
for I in 1..5 loop | ||
Put ('0'); | ||
end loop; | ||
end Write_Zeros; | ||
|
||
task body Write_Ones is | ||
begin | ||
for I in 1..5 loop | ||
Put ('1'); | ||
end loop; | ||
end Write_Ones; | ||
|
||
begin | ||
for I in 1..5 loop | ||
Put ('2'); | ||
end loop; | ||
end Ada_Thread; |
Binary file not shown.
Binary file not shown.
49 changes: 49 additions & 0 deletions
49
tests/test_suite_generator/src/linux/ada_trinary/ada_trinary.adb
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,49 @@ | ||
-- | ||
-- Copyright (c) 2017 Trail of Bits, Inc. | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
|
||
with Ada.Text_IO; | ||
use Ada.Text_IO; | ||
|
||
procedure Ada_Trinary is | ||
task Task1; | ||
task Task2; | ||
|
||
Task_Var1 : Integer := 0; | ||
Task_Var2 : Integer := 0; | ||
|
||
task body Task1 is | ||
begin | ||
for I in 1..2000 loop | ||
Task_Var1 := Task_Var1 + I; | ||
-- Put_Line ("Task 1 " & Integer'Image(Task_Var1)); | ||
end loop; | ||
end Task1; | ||
|
||
task body Task2 is | ||
begin | ||
for I in 1..2000 loop | ||
Task_Var2 := Task_Var2 + I; | ||
-- Put_Line ("Task 2 " & Integer'Image(Task_Var2)); | ||
end loop; | ||
end Task2; | ||
|
||
begin | ||
loop | ||
delay Duration(0.1); | ||
exit when Task_Var1 = Task_Var2; | ||
end loop; | ||
Put_Line ("Test Passed " & Integer'Image(Task_Var1)); | ||
end Ada_Trinary; |
Binary file not shown.
53 changes: 53 additions & 0 deletions
53
tests/test_suite_generator/src/linux/ada_worker/ada_worker.adb
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,53 @@ | ||
with Ada.Command_Line; | ||
with Ada.Text_IO; | ||
|
||
procedure Ada_Worker is | ||
Iterations : Positive := Positive'Value(Ada.Command_Line.Argument (1)); | ||
protected Buffer is | ||
entry Put (X : in Boolean); | ||
entry Get (X : out Boolean); | ||
private | ||
Value : Boolean; | ||
Full : Boolean := False; | ||
end Buffer; | ||
|
||
protected body Buffer is | ||
entry Put (X : in Boolean) when not Full is | ||
begin | ||
Value := X; | ||
Full := True; | ||
end Put; | ||
entry Get (X : out Boolean) when Full is | ||
begin | ||
X := Value; | ||
Full := False; | ||
end Get; | ||
end Buffer; | ||
|
||
|
||
task Ada_Producer; | ||
task Ada_Consumer; | ||
|
||
task body Ada_Producer is | ||
begin | ||
for I in 1 .. Iterations - 1 loop | ||
Buffer.Put (False); | ||
end loop; | ||
Buffer.Put (True); | ||
end Ada_Producer; | ||
|
||
task body Ada_Consumer is | ||
X : Boolean; | ||
Count : Natural := 0; | ||
begin | ||
loop | ||
Buffer.Get (X); | ||
Count := Count + 1; | ||
exit when X; | ||
end loop; | ||
Ada.Text_IO.Put_Line ("Executed " & Natural'Image (Count) & " iterations"); | ||
end Ada_Consumer; | ||
|
||
begin | ||
null; | ||
end Ada_Worker; |
28 changes: 28 additions & 0 deletions
28
tests/test_suite_generator/src/linux/pthread1/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,28 @@ | ||
# Copyright (c) 2017 Trail of Bits, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specifi | ||
|
||
project(pthread1) | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
set(PROJECT_CXXFLAGS -Wall -Werror) | ||
set(PROJECT_LDFLAGS -lpthread) | ||
|
||
set(PROJECT_SOURCEFILES | ||
main.c | ||
) | ||
|
||
GenerateTest(${PROJECT_NAME} | ||
SOURCES ${PROJECT_SOURCEFILES} | ||
CXXFLAGS ${PROJECT_CXXFLAGS} | ||
LDFLAGS ${PROJECT_LDFLAGS} | ||
) |
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,77 @@ | ||
/* | ||
* Copyright (c) 2017 Trail of Bits, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
|
||
__thread int tls_data1; | ||
__thread int tls_data2; | ||
|
||
typedef struct { | ||
int data1; | ||
int data2; | ||
} thread_parm_t; | ||
|
||
void bar() { | ||
printf("bar(), tls data=%d %d\n", tls_data1, tls_data2); | ||
return; | ||
} | ||
|
||
void foo() { | ||
printf("foo(), tls data=%d %d\n", tls_data1, tls_data2); | ||
bar(); | ||
} | ||
|
||
void *theThread(void *parm) | ||
{ | ||
int rc; | ||
thread_parm_t *gData; | ||
gData = (thread_parm_t*)parm; | ||
tls_data1 = gData->data1; | ||
tls_data2 = gData->data2; | ||
foo(); | ||
return NULL; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
int rc=0, i; | ||
pthread_t thread[2]; | ||
thread_parm_t gData[2]; | ||
|
||
printf("Create threads\n"); | ||
for (i=0; i < 2; i++) { | ||
gData[i].data1 = i; | ||
gData[i].data2 = (i+1)*2; | ||
rc = pthread_create(&thread[i], NULL, theThread, &gData[i]); | ||
if (rc) { | ||
printf("Failed with %d at pthread_create()", rc); | ||
exit(1); | ||
} | ||
} | ||
|
||
printf("Wait for the threads to complete, and release their resources\n"); | ||
for (i=0; i < 2; i++) { | ||
rc = pthread_join(thread[i], NULL); | ||
if (rc) { | ||
printf("Failed with %d at pthread_join()", rc); | ||
exit(1); | ||
} | ||
} | ||
|
||
printf("Main completed\n"); | ||
return 0; | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/test_suite_generator/src/linux/pthread_worker/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,28 @@ | ||
# Copyright (c) 2017 Trail of Bits, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specifi | ||
|
||
project(pthread1) | ||
cmake_minimum_required(VERSION 3.2) | ||
|
||
set(PROJECT_CXXFLAGS -Wall -Werror) | ||
set(PROJECT_LDFLAGS -lpthread) | ||
|
||
set(PROJECT_SOURCEFILES | ||
main.cpp | ||
) | ||
|
||
GenerateTest(${PROJECT_NAME} | ||
SOURCES ${PROJECT_SOURCEFILES} | ||
CXXFLAGS ${PROJECT_CXXFLAGS} | ||
LDFLAGS ${PROJECT_LDFLAGS} | ||
) |
Oops, something went wrong.