Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite: Initial port #417

Open
wants to merge 22 commits into
base: loader
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "src/components/lib/ck/ck"]
path = src/components/lib/ck/ck
url = https://github.com/gwsystems/ck.git
[submodule "src/components/lib/sqlite/sqlite"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to move this into gwsystems. Remember, we want the main branch of the repo be unmodifed, and have a cos branch that we pull in as a submodule. That way we have a path for updating the code as upstream changes.

path = src/components/lib/sqlite/sqlite
url = https://github.com/msdx321/sqlite.git
29 changes: 29 additions & 0 deletions composition_scripts/sqlite_tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[system]
description = "Simple test of sqlite."

[[components]]
name = "booter"
img = "no_interface.llbooter"
implements = [{interface = "init"}, {interface = "addr"}]
deps = [{srv = "kernel", interface = "init", variant = "kernel"}]
constructor = "kernel"

[[components]]
name = "capmgr"
img = "capmgr.simple"
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}]
implements = [{interface = "capmgr"}, {interface = "init"}, {interface = "memmgr"}, {interface = "capmgr_create"}]
constructor = "booter"

[[components]]
name = "sched"
img = "sched.root_fprr"
deps = [{srv = "capmgr", interface = "init"}, {srv = "capmgr", interface = "capmgr"}, {srv = "capmgr", interface = "memmgr"}]
implements = [{interface = "sched"}, {interface = "init"}]
constructor = "booter"

[[components]]
name = "sqlite_tests"
img = "tests.sqlite_tests"
deps = [{srv = "sched", interface = "init"}, {srv = "sched", interface = "sched"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "capmgr", interface = "memmgr"}, {srv = "capmgr", interface = "capmgr"}]
constructor = "booter"
18 changes: 18 additions & 0 deletions src/components/implementation/tests/sqlite_tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Required variables used to drive the compilation process. It is OK
# for many of these to be empty.
#
# The set of interfaces that this component exports for use by other
# components. This is a list of the interface names.
INTERFACE_EXPORTS =
# The interfaces this component is dependent on for compilation (this
# is a list of directory names in interface/)
INTERFACE_DEPENDENCIES =
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component sqlite
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
# minimality; that's on you!

include Makefile.subsubdir
9 changes: 9 additions & 0 deletions src/components/implementation/tests/sqlite_tests/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## tests

This is the skeleton interface used by the `mkcomponent.sh` script to aid in the creation of a new component.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation here, or remove the file.

It provides no functionality, and should never be depended on!
This documentation should be *replaced* in the documentation for a new component.

### Description

### Usage and Assumptions
44 changes: 44 additions & 0 deletions src/components/implementation/tests/sqlite_tests/sqlite_tests.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <cos_component.h>
#include <llprint.h>
#include <sqlite3.h>
#include <cos_defkernel_api.h>

void
cos_init(void)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove this function, it should still work. If you don't have code in it, remove it!

{
}

int result_print(void *v, int argc, char **argv,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your line width wraparound seems too aggressive. I don't think that the argument needs to be on another line.

char **col_name) {
for (int i = 0; i < argc; i++) {
printc("%s = %s\n", col_name[i], argv[i] ? argv[i] : "NULL");
}

return 0;
}

int
main(void)
{
printc("Calling sqlite functions\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent indentation styules. likely mixing spaces and tabs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable definitions should be at the top of the block.


sqlite3 *db;
char *err_msg = 0;
char *sql = "CREATE TABLE TestTable(Id INTEGER PRIMARY KEY, Value TEXT);"
"INSERT INTO TestTable(Value) VALUES ('TestItem1');"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal opinion (ignore if you'd like): all strings would look better if the starting "s were aligned.

"INSERT INTO TestTable(Value) VALUES ('TestItem2');"
"INSERT INTO TestTable(Value) VALUES ('TestItem3');"
"INSERT INTO TestTable(Value) VALUES ('TestItem4');"
"INSERT INTO TestTable(Value) VALUES ('TestItem5');";

sqlite3_open(":memory:", &db);

sqlite3_exec(db, sql, 0, 0, &err_msg);

sql = "SELECT * FROM TestTable WHERE Id == 3";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation again.

sqlite3_exec(db, sql, result_print, 0, &err_msg);

sqlite3_close(db);

while(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after keywords

}
2 changes: 1 addition & 1 deletion src/components/lib/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# NOTE: libc is special-cased and the compilation is orchestrated
# directly. It should have no dependencies.
LIBRARY_OUTPUT = c crypt m thread resolv rt
LIBRARY_OUTPUT = c crypt m pthread resolv rt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!!!

# The .o files that are mandatorily linked into dependents. This is
# rarely used, and only when normal .a linking rules will avoid
# linking some necessary objects. This list is of names (for example,
Expand Down
4 changes: 2 additions & 2 deletions src/components/lib/posix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ OBJECT_OUTPUT = posix
INCLUDE_PATHS = .
# The interfaces this component is dependent on for compilation (this
# is a list of directory names in interface/)
INTERFACE_DEPENDENCIES =
INTERFACE_DEPENDENCIES = capmgr
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component kernel sl
LIBRARY_DEPENDENCIES = component kernel
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
Expand Down
Loading