generated from par-tec/python-cookiecutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e594a9d
commit f4f1aab
Showing
8 changed files
with
452 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CC=gcc | ||
CFLAGS=-fPIC -g | ||
|
||
all: example example.so | ||
|
||
example: example.o | ||
$(CC) -o example example.o $(CFLAGS) | ||
|
||
example.o: example.c | ||
$(CC) -c example.c $(CFLAGS) | ||
|
||
example.so: example.o | ||
$(CC) -shared -o example.so example.o | ||
|
||
clean: | ||
rm -f example example.o example.so | ||
rm -f example example.o |
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,78 @@ | ||
/** | ||
* A C file with a library function that appends a buffer to a linked list. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <search.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#include "example.h" | ||
|
||
|
||
static element * | ||
new_element(void) | ||
{ | ||
element *e; | ||
|
||
e = malloc(sizeof(*e)); | ||
if (e == NULL) | ||
{ | ||
fprintf(stderr, "malloc() failed\n"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
return e; | ||
} | ||
|
||
|
||
|
||
element* append(queue *q, char *name) { | ||
element *elem, *prev; | ||
|
||
if (!q) return NULL; // Check if the queue pointer itself is NULL | ||
|
||
elem = new_element(); | ||
if (!elem) return NULL; // Check if memory allocation failed | ||
|
||
elem->name = name; // Assuming name is properly allocated and managed outside this function | ||
|
||
if (!*q) { | ||
// If the queue is empty, insert the new element at the beginning | ||
*q = elem; | ||
} else { | ||
// Find the last element in the queue | ||
for (prev = *q; prev->forward != NULL; prev = prev->forward) | ||
; | ||
// Insert the new element at the end of the queue | ||
} | ||
insque(elem, prev); | ||
|
||
return elem; | ||
} | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
element *first, *elem, *prev; | ||
queue *q = malloc(sizeof(queue)); | ||
|
||
elem = append(q, "1"); | ||
|
||
|
||
printf("Traversing completed list:\n"); | ||
elem = first; | ||
do | ||
{ | ||
printf(" %s\n", elem->name); | ||
elem = elem->forward; | ||
} while (elem != NULL && elem != first); | ||
|
||
if (elem == first) | ||
printf("That was a circular list\n"); | ||
|
||
exit(EXIT_SUCCESS); | ||
} |
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,8 @@ | ||
typedef struct element | ||
{ | ||
struct element *forward; | ||
struct element *backward; | ||
char *name; | ||
} element; | ||
|
||
typedef element* queue; |
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 |
---|---|---|
|
@@ -31,4 +31,4 @@ | |
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
</project> |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import jpype | ||
|
||
|
||
def test_noop(): | ||
|
||
jpype.startJVM(jpype.getDefaultJVMPath()) | ||
|
||
Random = jpype.JClass('java.util.Random') | ||
String = jpype.JClass('java.lang.String') | ||
System = jpype.JClass('java.lang.System') | ||
Random = jpype.JClass("java.util.Random") | ||
String = jpype.JClass("java.lang.String") | ||
System = jpype.JClass("java.lang.System") | ||
# Create an instance of java.util.Random | ||
random = Random() | ||
for _ in range(20): | ||
System.out.println(String.format("Random number: %d", random.nextInt())) | ||
|
||
# Shutdown the JVM | ||
jpype.shutdownJVM() | ||
jpype.shutdownJVM() |
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,17 @@ | ||
import ctypes | ||
import struct | ||
from ctypes import Structure, c_char, c_int, c_longlong, c_uint16 | ||
from pathlib import Path | ||
|
||
import model | ||
import pytest | ||
import yaml | ||
|
||
# Load libraries. | ||
libpmc_so = Path(__file__).parent / "libpmc.so" | ||
messages_yaml = Path(__file__).parent / "messages.yaml" | ||
libpmc = ctypes.CDLL(libpmc_so.as_posix()) | ||
libc = ctypes.CDLL("libc.so.6") | ||
|
||
# Load testcases. | ||
messages = yaml.safe_load(messages_yaml.read_text())["messages"] |
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