• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 11056227752

26 Sep 2024 04:17PM UTC coverage: 55.885% (-0.007%) from 55.892%
11056227752

push

github

web-flow
Fixed one warning message at shutdown after checkpoint load and kept the current multicast group after checkpoint load. (#1784)

* Added a check before calling MM delete_var in ExternalApplication destructor;
Made sure that the MulticastGroup is not initialized before initializing it in VariableServerListenThread.cpp;

* Updated to call multicast group initialization to be consistent for the unit test.

* Removed unnecessary command c str pointer.

* Removed unnecessary command c str pointer.

2 of 3 new or added lines in 2 files covered. (66.67%)

2 existing lines in 1 file now uncovered.

12288 of 21988 relevant lines covered (55.89%)

69028.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.63
/trick_source/sim_services/ExternalApplications/ExternalApplication.cpp
1

2
#include <sstream>
3
#include <iostream>
4
#include <stdlib.h>
5
#include <dlfcn.h>
6
#include <vector>
7
#include <cstring>
8

9
#include "trick/ExternalApplication.hh"
10
#include "trick/ExternalApplicationManager.hh"
11
#include "trick/variable_server_proto.h"
12
#include "trick/env_proto.h"
13
#include "trick/command_line_protos.h"
14
#include "trick/MemoryManager.hh"
15
extern Trick::MemoryManager* trick_MM;
16

17
Trick::ExternalApplication::ExternalApplication() :
887✔
18
    command(std::string(env_get_var("TRICK_HOME") + std::string("/bin/"))) {
887✔
19
    host_source = port_source = AUTO;
887✔
20
    cycle_period_set = minimum_cycle_period_set = disconnect_behavior_set = height_set =
887✔
21
      width_set = x_set = y_set = auto_reconnect_set = false;
887✔
22
}
887✔
23

24
Trick::ExternalApplication::~ExternalApplication() {
887✔
25
}
887✔
26

27
void Trick::ExternalApplication::set_startup_command(std::string in_command) {
×
28
    command = in_command;
×
29
}
×
30

31
std::string Trick::ExternalApplication::get_startup_command() {
×
32
    return command;
×
33
}
34

35
const char * Trick::ExternalApplication::get_startup_command_c_str() {
×
NEW
36
    return command.c_str();
×
37
}
38

39
void Trick::ExternalApplication::add_arguments(std::string args) {
×
40
    arguments << " " << args;
×
41
}
×
42

43
void Trick::ExternalApplication::set_arguments(std::string args) {
×
44
    arguments.str(args);
×
45
    host_source = port_source = NONE;
×
46
    cycle_period_set = disconnect_behavior_set = height_set = width_set = x_set = y_set = false;
×
47
}
×
48

49
std::string Trick::ExternalApplication::get_arguments() {
×
50
    return arguments.str() + create_arguments_string();
×
51
}
52

53
void Trick::ExternalApplication::set_host(std::string in_host) {
×
54
    host = in_host;
×
55
    host_source = USER;
×
56
}
×
57

58
std::string Trick::ExternalApplication::get_host() {
×
59
    return host;
×
60
}
61

62
void Trick::ExternalApplication::set_port(unsigned short in_port) {
×
63
    port = in_port;
×
64
    port_source = USER;
×
65
}
×
66

67
unsigned short Trick::ExternalApplication::get_port() {
×
68
    return port;
×
69
}
70

71
void Trick::ExternalApplication::set_auto_reconnect(bool in_auto_reconnect) {
×
72
    auto_reconnect = in_auto_reconnect;
×
73
    auto_reconnect_set = true;
×
74
}
×
75

76
bool Trick::ExternalApplication::get_auto_reconnect() {
×
77
    return auto_reconnect;
×
78
}
79

80
void Trick::ExternalApplication::set_cycle_period(double in_cycle_period) {
×
81
    cycle_period = in_cycle_period;
×
82
    cycle_period_set = true;
×
83
}
×
84

85
double Trick::ExternalApplication::get_cycle_period() {
×
86
    return cycle_period;
×
87
}
88

89
void Trick::ExternalApplication::set_minimum_cycle_period(double in_minimum_cycle_period) {
×
90
    minimum_cycle_period = in_minimum_cycle_period;
×
91
    minimum_cycle_period_set = true;
×
92
}
×
93

94
double Trick::ExternalApplication::get_minimum_cycle_period() {
×
95
    return minimum_cycle_period;
×
96
}
97

98
void Trick::ExternalApplication::set_disconnect_behavior(DisconnectBehavior in_disconnect_behavior) {
×
99
    disconnect_behavior = in_disconnect_behavior;
×
100
    disconnect_behavior_set = true;
×
101
}
×
102

103
Trick::ExternalApplication::DisconnectBehavior Trick::ExternalApplication::get_disconnect_behavior() {
×
104
    return disconnect_behavior;
×
105
}
106

107
void Trick::ExternalApplication::set_height(int in_height) {
×
108
    height = in_height;
×
109
    height_set = true;
×
110
}
×
111

112
int Trick::ExternalApplication::get_height() {
×
113
    return height;
×
114
}
115

116
void Trick::ExternalApplication::set_width(int in_width) {
×
117
    width = in_width;
×
118
    width_set = true;
×
119
}
×
120

121
int Trick::ExternalApplication::get_width() {
×
122
    return width;
×
123
}
124

125
void Trick::ExternalApplication::set_x(int in_x) {
×
126
    x = in_x;
×
127
    x_set = true;
×
128
}
×
129

130
int Trick::ExternalApplication::get_x() {
×
131
    return x;
×
132
}
133

134
void Trick::ExternalApplication::set_y(int in_y) {
×
135
    y = in_y;
×
136
    y_set = true;
×
137
}
×
138

139
int Trick::ExternalApplication::get_y() {
×
140
    return y;
×
141
}
142

143
/** @par Detailed Design */
144
void Trick::ExternalApplication::launch() {
×
145
    /** <ul><li> If the application is enabled: */
146
    if (var_server_get_enabled()) {
×
147
        /** <ul><li> Execute the command and pass it any arguments. */
148
        std::ostringstream oss;
×
149

150
        int argc;
151
        char **argv;
152

153
        argc = command_line_args_get_argc() ;
×
154
        argv = command_line_args_get_argv() ;
×
155

156
        oss << command << " " << arguments.str() << " " << create_arguments_string() ;
×
157
        oss << " &";
×
158

159
        std::cout << oss.str() << std::endl;
×
160
        system(oss.str().c_str());
×
161
    }
162
}
×
163

164
std::string Trick::ExternalApplication::create_arguments_string() {
×
165
    std::ostringstream oss;
×
166

167
    switch (host_source) {
×
168
        case AUTO:
×
169
            host = var_server_get_hostname();
×
170
        case USER:
×
171
            oss << " --host " << host;
×
172
        case NONE:
×
173
            break;
×
174
    }
175

176
    switch (port_source) {
×
177
        case AUTO:
×
178
            port = var_server_get_port();
×
179
        case USER:
×
180
            oss << " --port " << port;
×
181
        case NONE:
×
182
            break;
×
183
    }
184

185
    if (minimum_cycle_period_set) {
×
186
        oss << " --minCycle " << minimum_cycle_period;
×
187
    }
188

189
    if (cycle_period_set) {
×
190
        oss << " --cycle " << cycle_period;
×
191
    }
192

193
    if (disconnect_behavior_set) {
×
194
        switch(disconnect_behavior) {
×
195
            case CLOSE:
×
196
                oss << " --disconnectBehavior Close";
×
197
                break;
×
198
            case NOTIFY:
×
199
                oss << " --disconnectBehavior Notify";
×
200
                break;
×
201
            case NOTHING:
×
202
                oss << " --disconnectBehavior Nothing";
×
203
                break;
×
204
            default:
×
205
                std::cout << __FILE__ << ":" << __LINE__ << ":  [33;1mwarning: [0m "
×
206
                          << "Ignoring invalid value (" << disconnect_behavior
×
207
                          << ") for disconnect_behavior." << std::endl;
×
208
                break;
×
209
        }
210
    }
211

212
    if (height_set) {
×
213
        oss << " --height " << height;
×
214
    }
215

216
    if (width_set) {
×
217
        oss << " --width " << width;
×
218
    }
219

220
    if (x_set) {
×
221
        oss << " --x " << x;
×
222
    }
223

224
    if (y_set) {
×
225
        oss << " --y " << y;
×
226
    }
227

228
    if (auto_reconnect_set) {
×
229
        oss << " --autoReconnect " << (auto_reconnect ? "true" : "false");
×
230
    }
231

232
    return oss.str();
×
233
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc