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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/*
* Copyright 2019 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
// 5s is too short for some SMTP servers
private const int TIMEOUT = 10;
public struct Integration.Configuration {
Geary.Protocol type;
Geary.ServiceProvider provider;
Geary.ServiceInformation service;
Geary.Endpoint target;
Geary.Credentials credentials;
}
int main(string[] args) {
/*
* Initialise all the things.
*/
// Ensure things like e.g. GLib's formatting routines uses a
// UTF-8-based locale rather ASCII
GLib.Intl.setlocale(LocaleCategory.ALL, "C.UTF-8");
Test.init(ref args);
Geary.RFC822.init();
Geary.HTML.init();
Geary.Logging.init();
Geary.Logging.log_to(stderr);
GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
Integration.Configuration config = load_config(args);
/*
* Hook up all tests into appropriate suites
*/
TestSuite integration = new TestSuite("integration");
switch (config.type) {
case IMAP:
integration.add_suite(new Integration.Imap.ClientSession(config).suite);
break;
case SMTP:
integration.add_suite(new Integration.Smtp.ClientSession(config).suite);
break;
}
/*
* Run the tests
*/
TestSuite root = TestSuite.get_root();
root.add_suite(integration);
MainLoop loop = new MainLoop();
int ret = -1;
Idle.add(() => {
ret = Test.run();
loop.quit();
return false;
});
loop.run();
return ret;
}
private Integration.Configuration load_config(string[] args) {
int i = 1;
try {
Geary.Protocol type = Geary.Protocol.for_value(args[i++]);
Geary.ServiceProvider provider = Geary.ServiceProvider.for_value(
args[i++]
);
Geary.ServiceInformation service = new Geary.ServiceInformation(
type, provider
);
if (provider == OTHER) {
service.host = args[i++];
service.port = service.get_default_port();
}
Geary.Credentials credentials = new Geary.Credentials(
PASSWORD, args[i++], args[i++]
);
provider.set_service_defaults(service);
Geary.Endpoint target = new Geary.Endpoint(
new NetworkAddress(service.host, service.port),
service.transport_security,
TIMEOUT
);
return { type, provider, service, target, credentials };
} catch (GLib.Error err) {
error(
"Error loading config: %s",
(new Geary.ErrorContext(err)).format_full_error()
);
}
}
|