add examples and run script for libpq and libpqxx libraries.
Signed-off-by: Alexy Gallardo Segura <alexy@uclv.cu>
This commit is contained in:
committed by
Norman Feske
parent
d23f6adcb8
commit
45705e99c3
113
run/libpq_create_db.run
Normal file
113
run/libpq_create_db.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpq/db_create
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-libpq_create">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-libpq_create
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
115
run/libpq_createdb_db.run
Normal file
115
run/libpq_createdb_db.run
Normal file
@@ -0,0 +1,115 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpq/db_createdb
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-libpq_createdb">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
# The QtQuick plugin currently needs to be provided both in the file system
|
||||
# (for Qt) and as ROM module (for 'dlopen()').
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-libpq_createdb
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
112
run/libpq_list_db.run
Normal file
112
run/libpq_list_db.run
Normal file
@@ -0,0 +1,112 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpq/db_list
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-libpq_list_db">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-libpq_list_db
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
113
run/libpq_update_db.run
Normal file
113
run/libpq_update_db.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpq/db_update
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-libpq_update">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-libpq_update
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
113
run/libpqxx_conection.run
Normal file
113
run/libpqxx_conection.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/conection_test
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-conection">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-conection
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
113
run/libpqxx_creation_table.run
Normal file
113
run/libpqxx_creation_table.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/creation_table
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-creation_table">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-creation_table
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
113
run/libpqxx_delete_operation.run
Normal file
113
run/libpqxx_delete_operation.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/delete_operation
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-delete_operation">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-delete_operation
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
116
run/libpqxx_insert_operation.run
Normal file
116
run/libpqxx_insert_operation.run
Normal file
@@ -0,0 +1,116 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/insert_operation
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-insert_operation">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
# The QtQuick plugin currently needs to be provided both in the file system
|
||||
# (for Qt) and as ROM module (for 'dlopen()').
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-insert_operation
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
113
run/libpqxx_select_operation.run
Normal file
113
run/libpqxx_select_operation.run
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/select_operation
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-select_operation">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-select_operation
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
116
run/libpqxx_update_operation.run
Normal file
116
run/libpqxx_update_operation.run
Normal file
@@ -0,0 +1,116 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core
|
||||
init
|
||||
drivers/timer
|
||||
test/libpqxx/update_operation
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="CAP"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
<service name="SIGNAL"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append_if [have_spec gpio] config {
|
||||
<start name="gpio_drv">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
<config/>
|
||||
</start>}
|
||||
|
||||
append config {
|
||||
<start name="usb_drv">
|
||||
<resource name="RAM" quantum="12M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
<!--<nic mac="02:00:00:00:01:01" />-->
|
||||
</config>
|
||||
</start> }
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="test-update_operation">
|
||||
<resource name="RAM" quantum="128M"/>
|
||||
<config>
|
||||
<arg value="dbname=postgres hostaddr=10.12.119.178 port=5432 user=postgres password=ok"/>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.12.119.169" netmask="255.255.255.0" gateway="10.12.119.253">
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
</libc>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
#
|
||||
|
||||
# The QtQuick plugin currently needs to be provided both in the file system
|
||||
# (for Qt) and as ROM module (for 'dlopen()').
|
||||
|
||||
append boot_modules {
|
||||
core init
|
||||
timer
|
||||
test-update_operation
|
||||
ld.lib.so
|
||||
libc.lib.so
|
||||
libpq.lib.so
|
||||
libpqxx.lib.so
|
||||
lwip.lib.so
|
||||
libm.lib.so
|
||||
pthread.lib.so
|
||||
stdcxx.lib.so
|
||||
}
|
||||
|
||||
lappend_if [have_spec usb] boot_modules usb_drv
|
||||
lappend_if [have_spec gpio] boot_modules gpio_drv
|
||||
|
||||
append_platform_drv_boot_modules
|
||||
|
||||
build_boot_image $boot_modules
|
||||
|
||||
append qemu_args " -m 256"
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
30
src/lib/libpq/dummy_sig_method.c
Normal file
30
src/lib/libpq/dummy_sig_method.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* \brief Dummy implementations
|
||||
* \author Reinier Millo Sánchez
|
||||
* \author Alexy Gallardo Segura
|
||||
* \date 2015-11-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
int sigpending(sigset_t *set)
|
||||
{
|
||||
//*sig = SIGQUIT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sigwait(const sigset_t *set, int *sig)
|
||||
{
|
||||
*sig = SIGQUIT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
121
src/test/libpq/db_create/main.cc
Normal file
121
src/test/libpq/db_create/main.cc
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL C tutorial" on the url next.
|
||||
* URL=http://zetcode.com/db/postgresqlc/
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
void do_exit(PGconn *conn, PGresult *res) {
|
||||
|
||||
fprintf(stderr, "%s\n", PQerrorMessage(conn));
|
||||
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *conninfo;
|
||||
|
||||
if (argc > 0)
|
||||
conninfo = argv[0];
|
||||
else
|
||||
conninfo = "dbname=postgres";
|
||||
|
||||
PGconn *conn = PQconnectdb(conninfo);
|
||||
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
|
||||
fprintf(stderr, "Connection to database failed: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
PGresult *res = PQexec(conn, "DROP TABLE IF EXISTS Cars");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "CREATE TABLE Cars(Id INTEGER PRIMARY KEY," \
|
||||
"Name VARCHAR(20), Price INT)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(1,'Audi',52642)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
do_exit(conn, res);
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(2,'Mercedes',57127)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(3,'Skoda',9000)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(4,'Volvo',29000)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(5,'Bentley',350000)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(6,'Citroen',21000)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(7,'Hummer',41400)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(8,'Volkswagen',21600)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpq/db_create/target.mk
Normal file
3
src/test/libpq/db_create/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-libpq_create
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
|
||||
49
src/test/libpq/db_createdb/main.cc
Normal file
49
src/test/libpq/db_createdb/main.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL C tutorial" on the url next.
|
||||
* URL=http://zetcode.com/db/postgresqlc/
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
void do_exit(PGconn *conn, PGresult *res) {
|
||||
|
||||
fprintf(stderr, "%s\n", PQerrorMessage(conn));
|
||||
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *conninfo;
|
||||
|
||||
if (argc > 0)
|
||||
conninfo = argv[0];
|
||||
else
|
||||
conninfo = "dbname=postgres";
|
||||
|
||||
PGconn *conn = PQconnectdb(conninfo);
|
||||
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
|
||||
fprintf(stderr, "Connection to database failed: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
PGresult *res = PQexec(conn, "CREATE DATABASE baseDBTest;");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
do_exit(conn, res);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpq/db_createdb/target.mk
Normal file
3
src/test/libpq/db_createdb/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-libpq_createdb
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
|
||||
129
src/test/libpq/db_list/main.cc
Normal file
129
src/test/libpq/db_list/main.cc
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* testlibpq.c
|
||||
*
|
||||
* Test the C version of libpq, the PostgreSQL frontend library.
|
||||
*
|
||||
* This example is taken of official documentation web of Postgres for using libpq.
|
||||
*
|
||||
* URL=http://www.postgresql.org/docs/9.1/static/libpq-example.html
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
|
||||
static void
|
||||
exit_nicely(PGconn *conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *conninfo;
|
||||
PGconn *conn;
|
||||
PGresult *res;
|
||||
int nFields;
|
||||
int i,
|
||||
j;
|
||||
|
||||
/*
|
||||
* If the user supplies a parameter on the command line, use it as the
|
||||
* conninfo string; otherwise default to setting dbname=postgres and using
|
||||
* environment variables or defaults for all other connection parameters.
|
||||
*/
|
||||
if (argc > 0)
|
||||
conninfo = argv[0];
|
||||
else
|
||||
conninfo = "dbname=postgres";
|
||||
|
||||
/* Make a connection to the database */
|
||||
conn = PQconnectdb(conninfo);
|
||||
|
||||
/* Check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) != CONNECTION_OK)
|
||||
{
|
||||
fprintf(stderr, "Connection to database failed: %s",
|
||||
PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Our test case here involves using a cursor, for which we must be inside
|
||||
* a transaction block. We could do the whole thing with a single
|
||||
* PQexec() of "select * from pg_database", but that's too trivial to make
|
||||
* a good example.
|
||||
*/
|
||||
|
||||
/* Start a transaction block */
|
||||
res = PQexec(conn, "BEGIN");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Should PQclear PGresult whenever it is no longer needed to avoid memory
|
||||
* leaks
|
||||
*/
|
||||
|
||||
PQclear(res);
|
||||
|
||||
|
||||
/*
|
||||
* Fetch rows from pg_database, the system catalog of databases
|
||||
*/
|
||||
res = PQexec(conn, "DECLARE myportal CURSOR FOR select * from pg_database");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
{
|
||||
fprintf(stderr, "DECLARE CURSOR failed: %s", PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "FETCH ALL in myportal");
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
fprintf(stderr, "FETCH ALL failed: %s", PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
/* first, print out the attribute names */
|
||||
nFields = PQnfields(res);
|
||||
for (i = 0; i < nFields; i++)
|
||||
printf("%-15s", PQfname(res, i));
|
||||
printf("\n\n");
|
||||
|
||||
/* next, print out the rows */
|
||||
for (i = 0; i < PQntuples(res); i++)
|
||||
{
|
||||
for (j = 0; j < nFields; j++)
|
||||
printf("%-15s", PQgetvalue(res, i, j));
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
/* close the portal ... we don't bother to check for errors ... */
|
||||
res = PQexec(conn, "CLOSE myportal");
|
||||
PQclear(res);
|
||||
|
||||
/* end the transaction */
|
||||
res = PQexec(conn, "END");
|
||||
PQclear(res);
|
||||
|
||||
/* close the connection to the database and cleanup */
|
||||
PQfinish(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpq/db_list/target.mk
Normal file
3
src/test/libpq/db_list/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-libpq_list_db
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libpq libc config_args
|
||||
77
src/test/libpq/db_update/main.cc
Normal file
77
src/test/libpq/db_update/main.cc
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL C tutorial" on the url next.
|
||||
* URL=http://zetcode.com/db/postgresqlc/
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
void do_exit(PGconn *conn) {
|
||||
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *conninfo;
|
||||
|
||||
if (argc > 0)
|
||||
conninfo = argv[0];
|
||||
else
|
||||
conninfo = "dbname=postgres";
|
||||
|
||||
PGconn *conn = PQconnectdb(conninfo);
|
||||
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
|
||||
fprintf(stderr, "Connection to database failed: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
PGresult *res = PQexec(conn, "BEGIN");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
||||
printf("BEGIN command failed\n");
|
||||
PQclear(res);
|
||||
do_exit(conn);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn, "UPDATE Cars SET Price=23700 WHERE Id=8");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
||||
printf("UPDATE command failed\n");
|
||||
PQclear(res);
|
||||
do_exit(conn);
|
||||
}
|
||||
|
||||
res = PQexec(conn, "INSERT INTO Cars VALUES(9,'Mazda',27770)");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
||||
printf("INSERT command failed\n");
|
||||
PQclear(res);
|
||||
do_exit(conn);
|
||||
}
|
||||
|
||||
res = PQexec(conn, "COMMIT");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
||||
printf("COMMIT command failed\n");
|
||||
PQclear(res);
|
||||
do_exit(conn);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpq/db_update/target.mk
Normal file
3
src/test/libpq/db_update/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-libpq_update
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
|
||||
40
src/test/libpqxx/conection_test/main.cc
Normal file
40
src/test/libpqxx/conection_test/main.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
try{
|
||||
|
||||
connection C("dbname=postgres user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
Timer::Connection timer;
|
||||
timer.usleep(100000);
|
||||
|
||||
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpqxx/conection_test/target.mk
Normal file
3
src/test/libpqxx/conection_test/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-conection
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
52
src/test/libpqxx/creation_table/main.cc
Normal file
52
src/test/libpqxx/creation_table/main.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char * sql;
|
||||
|
||||
try{
|
||||
connection C("dbname=testdb user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create SQL statement */
|
||||
sql = "CREATE TABLE COMPANY(" \
|
||||
"ID INT PRIMARY KEY NOT NULL," \
|
||||
"NAME TEXT NOT NULL," \
|
||||
"AGE INT NOT NULL," \
|
||||
"ADDRESS CHAR(50)," \
|
||||
"SALARY REAL );";
|
||||
|
||||
/* Create a transactional object. */
|
||||
work W(C);
|
||||
|
||||
/* Execute SQL query */
|
||||
W.exec( sql );
|
||||
W.commit();
|
||||
cout << "Table created successfully" << endl;
|
||||
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
3
src/test/libpqxx/creation_table/target.mk
Normal file
3
src/test/libpqxx/creation_table/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-creation_table
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
62
src/test/libpqxx/delete_operation/main.cc
Normal file
62
src/test/libpqxx/delete_operation/main.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char * sql;
|
||||
|
||||
try{
|
||||
connection C("dbname=testdb user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a transactional object. */
|
||||
work W(C);
|
||||
/* Create SQL DELETE statement */
|
||||
sql = "DELETE from COMPANY where ID = 2";
|
||||
/* Execute SQL query */
|
||||
W.exec( sql );
|
||||
W.commit();
|
||||
cout << "Records deleted successfully" << endl;
|
||||
|
||||
/* Create SQL SELECT statement */
|
||||
sql = "SELECT * from COMPANY";
|
||||
|
||||
/* Create a non-transactional object. */
|
||||
nontransaction N(C);
|
||||
|
||||
/* Execute SQL query */
|
||||
result R( N.exec( sql ));
|
||||
|
||||
/* List down all the records */
|
||||
for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
|
||||
cout << "ID = " << c[0].as<int>() << endl;
|
||||
cout << "Name = " << c[1].as<string>() << endl;
|
||||
cout << "Age = " << c[2].as<int>() << endl;
|
||||
cout << "Address = " << c[3].as<string>() << endl;
|
||||
cout << "Salary = " << c[4].as<float>() << endl;
|
||||
}
|
||||
cout << "Operation done successfully" << endl;
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpqxx/delete_operation/target.mk
Normal file
3
src/test/libpqxx/delete_operation/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-delete_operation
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
53
src/test/libpqxx/insert_operation/main.cc
Normal file
53
src/test/libpqxx/insert_operation/main.cc
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char * sql;
|
||||
|
||||
try{
|
||||
connection C("dbname=testdb user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create SQL statement */
|
||||
sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
|
||||
"VALUES (1, 'Paul', 32, 'California', 20000.00 ); " \
|
||||
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
|
||||
"VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); " \
|
||||
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
|
||||
"VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );" \
|
||||
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
|
||||
"VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );";
|
||||
|
||||
/* Create a transactional object. */
|
||||
work W(C);
|
||||
|
||||
/* Execute SQL query */
|
||||
W.exec( sql );
|
||||
W.commit();
|
||||
cout << "Records created successfully" << endl;
|
||||
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpqxx/insert_operation/target.mk
Normal file
3
src/test/libpqxx/insert_operation/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-insert_operation
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
55
src/test/libpqxx/select_operation/main.cc
Normal file
55
src/test/libpqxx/select_operation/main.cc
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char * sql;
|
||||
|
||||
try{
|
||||
connection C("dbname=testdb user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create SQL statement */
|
||||
sql = "SELECT * from COMPANY";
|
||||
|
||||
/* Create a non-transactional object. */
|
||||
nontransaction N(C);
|
||||
|
||||
/* Execute SQL query */
|
||||
result R( N.exec( sql ));
|
||||
|
||||
/* List down all the records */
|
||||
for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
|
||||
cout << "ID = " << c[0].as<int>() << endl;
|
||||
cout << "Name = " << c[1].as<string>() << endl;
|
||||
cout << "Age = " << c[2].as<int>() << endl;
|
||||
cout << "Address = " << c[3].as<string>() << endl;
|
||||
cout << "Salary = " << c[4].as<float>() << endl;
|
||||
}
|
||||
|
||||
cout << "Operation done successfully" << endl;
|
||||
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpqxx/select_operation/target.mk
Normal file
3
src/test/libpqxx/select_operation/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-select_operation
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
61
src/test/libpqxx/update_operation/main.cc
Normal file
61
src/test/libpqxx/update_operation/main.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
|
||||
* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
using namespace std;
|
||||
using namespace pqxx;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char * sql;
|
||||
|
||||
try{
|
||||
connection C("dbname=testdb user=postgres password=ok \
|
||||
hostaddr=10.12.119.178 port=5432");
|
||||
if (C.is_open()) {
|
||||
cout << "Opened database successfully: " << C.dbname() << endl;
|
||||
} else {
|
||||
cout << "Can't open database" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a transactional object. */
|
||||
work W(C);
|
||||
/* Create SQL UPDATE statement */
|
||||
sql = "UPDATE COMPANY set SALARY = 25000.00 where ID=1";
|
||||
/* Execute SQL query */
|
||||
W.exec( sql );
|
||||
W.commit();
|
||||
cout << "Records updated successfully" << endl;
|
||||
|
||||
/* Create SQL SELECT statement */
|
||||
sql = "SELECT * from COMPANY";
|
||||
|
||||
/* Create a non-transactional object. */
|
||||
nontransaction N(C);
|
||||
|
||||
/* Execute SQL query */
|
||||
result R( N.exec( sql ));
|
||||
|
||||
/* List down all the records */
|
||||
for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
|
||||
cout << "ID = " << c[0].as<int>() << endl;
|
||||
cout << "Name = " << c[1].as<string>() << endl;
|
||||
cout << "Age = " << c[2].as<int>() << endl;
|
||||
cout << "Address = " << c[3].as<string>() << endl;
|
||||
cout << "Salary = " << c[4].as<float>() << endl;
|
||||
}
|
||||
cout << "Operation done successfully" << endl;
|
||||
C.disconnect ();
|
||||
|
||||
}catch (const std::exception &e){
|
||||
cerr << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
src/test/libpqxx/update_operation/target.mk
Normal file
3
src/test/libpqxx/update_operation/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = test-update_operation
|
||||
SRC_CC = main.cc
|
||||
LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
|
||||
Reference in New Issue
Block a user