about summary refs log tree commit diff stats
path: root/subx/teensy/test7-global.s
blob: 4cb4e8f34b00b82023e6b958d50a06e0a6ca9ba0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
; https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
; nasm -f bin test7-global.s -o test7
; chmod +x test7
BITS 32

              org     0x08048000

ehdr:                                                 ; Elf32_Ehdr
              db      0x7F, "ELF", 1, 1, 1, 0         ;   e_ident
      times 8 db      0
              dw      2                               ;   e_type
              dw      3                               ;   e_machine
              dd      1                               ;   e_version
              dd      _start                          ;   e_entry
              dd      phdr1 - $$                      ;   e_phoff
              dd      0                               ;   e_shoff
              dd      0                               ;   e_flags
              dw      ehdrsize                        ;   e_ehsize
              dw      phdrsize                        ;   e_phentsize
              dw      2                               ;   e_phnum
              dw      0                               ;   e_shentsize
              dw      0                               ;   e_shnum
              dw      0                               ;   e_shstrndx
ehdrsize  equ  $ - ehdr

phdr1:                                                ; Elf32_Phdr
              dd      1                               ;   p_type
              dd      0                               ;   p_offset
              dd      $$                              ;   p_vaddr
              dd      $$                              ;   p_paddr
              dd      codesize                        ;   p_filesz
              dd      codesize                        ;   p_memsz
              dd      5                               ;   p_flags = r-x
              dd      0x1000                          ;   p_align
phdrsize  equ  $ - phdr1

phdr2:
              dd      1                               ;   p_type
              dd      _data - $$                      ;   p_offset
              dd      _data                           ;   p_vaddr
              dd      _data                           ;   p_paddr
              dd      datasize                        ;   p_filesz
              dd      datasize                        ;   p_memsz
              dd      6                               ;   p_flags = rw-
              dd      0x1000                          ;   p_align

_start:
  mov ebx, [foo]
  mov eax, 1
  int 0x80

codesize      equ     $ - $$  ; TODO: why include the headers?!

alignb 0x1000
_data:
  foo:        dd      42

datasize      equ     $ - _data
ht .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>

#include <stabber.h>
#include <expect.h>

#include "proftest.h"

void
sends_room_join(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/stabber'>"
            "<x xmlns='http://jabber.org/protocol/muc'/>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_nick(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost nick testnick");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/testnick'>"
            "<x xmlns='http://jabber.org/protocol/muc'/>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_password(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost password testpassword");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/stabber'>"
            "<x xmlns='http://jabber.org/protocol/muc'>"
                "<password>testpassword</password>"
            "</x>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_nick_and_password(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost nick testnick password testpassword");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/testnick'>"
            "<x xmlns='http://jabber.org/protocol/muc'>"
                "<password>testpassword</password>"
            "</x>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
shows_role_and_affiliation_on_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");

    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
}

void
shows_subject_on_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>"
            "<subject>Test room subject</subject>"
            "<body>anothernick has set the subject to: Test room subject</body>"
        "</message>"
    );

    assert_true(prof_output_regex("Room subject: .+Test room subject"));
}

void
shows_history_message(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>an old message</body>"
            "<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
            "<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
        "</message>"
    );

    assert_true(prof_output_regex("testoccupant: an old message"));
}

void
shows_occupant_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<presence to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
            "</x>"
        "</presence>"
    );

    assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none"));
}

void
shows_message(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_regex("testoccupant: .+a new message"));
}

void
shows_me_message_from_occupant(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>/me did something</body>"
        "</message>"
    );

    assert_true(prof_output_exact("*testoccupant did something"));
}

void
shows_me_message_from_self(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<body>/me did something</body>"
        "</message>"
    );

    assert_true(prof_output_exact("*stabber did something"));
}

void
shows_all_messages_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
            "<body>some other message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
}

void
shows_first_message_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    prof_input("/console muc first");
    assert_true(prof_output_exact("Console MUC messages set: first"));

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
    prof_input("/clear");
    prof_input("/about");
    assert_true(prof_output_exact("Type '/help' to show complete help."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
            "<body>some other message</body>"
        "</message>"
    );

    prof_timeout(2);
    assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
    prof_timeout_reset();
}

void
shows_no_message_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    prof_input("/console muc none");
    assert_true(prof_output_exact("Console MUC messages set: none"));

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    prof_timeout(2);
    assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));
    prof_timeout_reset();
}