2 #define PORT_SENSORS 22471
12 #include <google/cmockery.h>
13 #include "sensors_packet.pb-c.h"
37 #define LOG_TAG "testSensors"
49 pthread_t sensor_thread;
57 SensorsPacket__SensorAccelerometerPayload payload =
58 SENSORS_PACKET__SENSOR_ACCELEROMETER_PAYLOAD__INIT;
67 int msglen = protobuf_c_message_get_packed_size((
const struct ProtobufCMessage*) &payload);
68 void* messagebody = malloc(msglen);
70 int len = protobuf_c_message_pack((
const struct ProtobufCMessage*) &payload, messagebody);
82 pthread_t* thread = malloc(
sizeof(*thread));
88 pthread_join(*thread, NULL);
90 assert_int_equal(1, params->
nbevent);
91 assert_int_equal(payload.x, params->
payload->x);
92 assert_int_equal(payload.y, params->
payload->y);
93 assert_int_equal(payload.z, params->
payload->z);
103 NfcPayload payload = NFC_PAYLOAD__INIT;
105 payload.has_lang = 1;
106 payload.has_type = 1;
109 payload.text =
"google.com";
111 int msglen = nfc_payload__get_packed_size(&payload);
112 void* messagebody = malloc(msglen);
114 int len = nfc_payload__pack(&payload, messagebody);
124 pthread_t* thread0 = malloc(
sizeof(*thread0));
127 pthread_join(*thread0, &retval);
158 int main(
int argc,
char* argv[])
163 LOGI(
"Starting sensor listening");
173 return run_tests(tests);
Utilities to get config values from the environment.
Utilities for consuming RabbitMQ messages.
SensorsPacket__SensorAccelerometerPayload * payload
sensor_params * ParamEventsWorker(const char *vmip, const char *vmid, const char *sensor_name, const char *amqp_host)
Creates the data structure for sensor threads.
void * mock_vm_recv_poll(void *args)
Parameter for sensor threads.
int main(int argc, char *argv[])
void test_sensors_acc(void **state)
char queue[BUF_SIZE]
Queue name.
void * listen_NFC(void *args)
Listen to AMQP and send data to the NFC sensor in the VM.
Defines ports and structures for sensor threads.
char * configvar_string(char *varname)
Get the value of a config variable from the env.
char exchange[BUF_SIZE]
Exchange name.
void start_sensor(sensor_params *params, pthread_t *thread)
Start the sensor listener thread.
void test_sensors_nfc(void **state)
Define common buffer sizes.
Define socket utilities to simplify networking.
#define LOGI(...)
Log at INFO level.
int amqp_send(char const *hostname, int port, char const *exchange, char const *bindingkey, int size, unsigned char *messagebody)
Send a payload to an AMQP exchange.