7 #include "../src/ceptr.h"
8 #include "../src/vmhost.h"
10 #include "../src/shell.h"
11 #include "../src/protocol.h"
18 spec_is_equal(sem->contexts,_NUM_DEFAULT_CONTEXTS);
19 spec_is_equal(
_t_children(
_t_child(sem->stores[0].definitions,SEM_TYPE_SYMBOL)),NUM_SYS_SYMBOLS-1);
20 spec_is_equal(
_t_children(
_t_child(sem->stores[0].definitions,SEM_TYPE_STRUCTURE)),NUM_SYS_STRUCTURES-1);
22 spec_is_str_equal(t2s(v->
r->
root),
"(RECEPTOR_INSTANCE (INSTANCE_OF:SYS_RECEPTOR) (CONTEXT_NUM:0) (PARENT_CONTEXT_NUM:-1) (RECEPTOR_STATE (FLUX (DEFAULT_ASPECT (EXPECTATIONS) (SIGNALS))) (PENDING_SIGNALS) (PENDING_RESPONSES) (CONVERSATIONS) (RECEPTOR_ELAPSED_TIME:0)))");
25 spec_is_sem_equal(v->installed_receptors->key_source,RECEPTOR_IDENTIFIER);
26 spec_is_sem_equal(v->installed_receptors->data_source,RECEPTOR_SURFACE);
259 _t_newi(noop,TEST_INT_SYMBOL,314);
263 T *res = _t_newr(binding,RESOLUTION);
264 _t_news(res,GOAL,HANDLER);
265 _t_news(res,ACTUAL_PROCESS,proc);
269 Xaddr sx = _v_new_receptor(v,v->
r,TEST_RECEPTOR,server);
270 Xaddr cx = _v_new_receptor(v,v->
r,TEST_RECEPTOR,client);
275 spec_is_equal(v->active_receptor_count,2);
280 spec_is_ptr_equal(ar,server);
282 spec_is_ptr_equal(ar,client);
284 _v_send(v,client->
addr,server->
addr,DEFAULT_ASPECT,ALIVE,_t_newi(0,PING,0));
286 spec_is_str_equal(_td(client,v->
r->pending_signals),
"(PENDING_SIGNALS (SIGNAL (ENVELOPE (FROM_ADDRESS (CONTEXT_NUM:3)) (TO_ADDRESS (CONTEXT_NUM:2)) (ASPECT_IDENT:DEFAULT_ASPECT) (CARRIER:ALIVE) (SIGNAL_UUID)) (BODY:{(PING)})))");
308 void testVMHostShell() {
319 char commands[] =
"receptors\ntime\n";
320 input = fmemopen(commands, strlen(commands),
"r");
321 char *output_data = NULL;
323 output = open_memstream(&output_data,&size);
325 Stream *output_stream, *input_stream;
328 makeShell(G_vm,input,output,&i_r,&o_r,&input_stream,&output_stream);
331 _v_start_vmhost(G_vm);
333 debug_disable(D_STREAM+D_SIGNALS+D_TREE+D_PROTOCOL);
343 spec_is_true(output_data != 0);
344 if (output_data != 0) {
346 spec_is_str_equal(output_data,
"COMPOSITORY:0 DEV_COMPOSITORY:1 TEST_RECEPTOR:2 CLOCK_RECEPTOR:3 shell:4 STREAM_EDGE:5 STREAM_EDGE:6 \n(TICK (TODAY (YEAR:");}
349 _v_join_thread(&G_vm->clock_thread);
350 _v_join_thread(&G_vm->vm_thread);
362 void testVMHostSerialize() {
366 spec_is_str_equal(t2s(G_vm->
r->
root),
"(SYS_RECEPTOR (DEFINITIONS (STRUCTURES) (SYMBOLS) (PROCESSES) (PROTOCOLS) (SCAPES)) (FLUX (DEFAULT_ASPECT (EXPECTATIONS) (SIGNALS))) (RECEPTOR_STATE) (PENDING_SIGNALS) (PENDING_RESPONSES))");
375 spec_is_str_equal(t2s(r->
root),
"(SYS_RECEPTOR (DEFINITIONS (STRUCTURES) (SYMBOLS) (PROCESSES) (PROTOCOLS) (SCAPES)) (FLUX (DEFAULT_ASPECT (EXPECTATIONS) (SIGNALS))) (RECEPTOR_STATE) (PENDING_SIGNALS) (PENDING_RESPONSES))");
378 _v_join_thread(&G_vm->clock_thread);
T * _t_new_root(Symbol symbol)
void _r_serialize(Receptor *r, void **surfaceP, size_t *lengthP)
void _v_send(VMHost *v, ReceptorAddress from, ReceptorAddress to, Aspect aspect, Symbol carrier, T *contents)
void _v_instantiate_builtins(VMHost *v)
void _r_free(Receptor *r)
T * _t_child(T *t, int i)
ReceptorAddress addr
the address by which to get messages to this receptor instance
VMHost * _v_new()
Creates a new virtual machine host.
void _v_activate(VMHost *v, Xaddr x)
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
SemTable * sem
Semantic Table for definitions on this host.
Receptor * _r_unserialize(SemTable *sem, void *surface)
void testVMHostActivateReceptor()
void _st_free(Stream *st)
T * root
RECEPTOR_INSTANCE semantic tree.
SemTable * sem
pointer back to the genotype table for this receptor's vmhost instance
ActiveReceptor active_receptors[MAX_ACTIVE_RECEPTORS]
pointer to array that holds all currently active receptors
void _o_express_role(Receptor *r, Protocol protocol, Symbol role, Aspect aspect, T *bindings)
Receptor * r
Receptor data for this vm host.
Qe * completed
completed processes (pending cleanup)
void _v_deliver_signals(VMHost *v, Receptor *sender)
Process _r_define_process(Receptor *r, T *code, char *name, char *intention, T *signature, T *link)