Skip to content

Commit dea732b

Browse files
authored
Urm Cleanup and delete unnecessary files (#207)
--- Signed-off-by: Kartik Nema <kartnema@qti.qualcomm.com>
1 parent 4b5977c commit dea732b

8 files changed

Lines changed: 17 additions & 30 deletions

File tree

TODO.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

contextual-classifier/FeatureExtractor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static std::string format_string(const char *fmt, ...) {
3434
return std::string(buffer);
3535
}
3636

37-
bool FeatureExtractor::IsValidPidViaProc(pid_t pid) {
37+
int8_t FeatureExtractor::IsValidPidViaProc(pid_t pid) {
3838
std::string procPath = "/proc/" + std::to_string(pid);
3939
struct stat info;
4040
return (stat(procPath.c_str(), &info) == 0 && S_ISDIR(info.st_mode));
@@ -52,7 +52,7 @@ std::string join_vector(const std::vector<std::string> &vec) {
5252
}
5353

5454
int FeatureExtractor::CollectAndStoreData( pid_t pid,
55-
std::map<std::string, std::string> &output_data, bool dump_csv) {
55+
std::map<std::string, std::string> &output_data, int8_t dump_csv) {
5656
if (!IsValidPidViaProc(pid)) {
5757
LOGE(SCANNER_TAG,
5858
format_string("PID %d does not exist in /proc.", pid));
@@ -482,7 +482,7 @@ FeatureExtractor::ParseFd(pid_t pid, const std::string &delimiters) {
482482
FeaturePruner::removeDatesAndTimesFromToken(tok);
483483
if (cleaned.empty())
484484
continue;
485-
bool isNumber =
485+
int8_t isNumber =
486486
std::all_of(cleaned.begin(), cleaned.end(), ::isdigit);
487487
if (isNumber)
488488
continue;

contextual-classifier/FeaturePruner.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ std::string FeaturePruner::removePunctuation(const std::string &s) {
100100
return out;
101101
}
102102

103-
bool FeaturePruner::isSingleCharToken(const std::string &s) {
103+
int8_t FeaturePruner::isSingleCharToken(const std::string &s) {
104104
return s.size() == 1;
105105
}
106106

107-
bool FeaturePruner::isAllSpecialChars(const std::string &token) {
107+
int8_t FeaturePruner::isAllSpecialChars(const std::string &token) {
108108
if (token.empty())
109109
return false;
110110
for (size_t i = 0; i < token.size(); ++i) {
@@ -116,12 +116,12 @@ bool FeaturePruner::isAllSpecialChars(const std::string &token) {
116116
return true;
117117
}
118118

119-
bool FeaturePruner::hasDigit(const std::string &str) {
119+
int8_t FeaturePruner::hasDigit(const std::string &str) {
120120
std::regex digitRegex("[0-9]");
121121
return std::regex_search(str, digitRegex);
122122
}
123123

124-
bool FeaturePruner::isDigitsOnly(const std::string &str) {
124+
int8_t FeaturePruner::isDigitsOnly(const std::string &str) {
125125
return !str.empty() && std::all_of(str.begin(), str.end(), ::isdigit);
126126
}
127127

contextual-classifier/Include/FeatureExtractor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FeatureExtractor {
5454
static std::vector<std::string>
5555
ExtractProcessNameAndMessage(const std::vector<std::string> &journalLines);
5656

57-
static bool IsValidPidViaProc(pid_t pid);
57+
static int8_t IsValidPidViaProc(pid_t pid);
5858

5959
public:
6060
FeatureExtractor() {
@@ -69,7 +69,7 @@ class FeatureExtractor {
6969
static int CollectAndStoreData(
7070
pid_t pid,
7171
std::map<std::string, std::string> &output_data,
72-
bool dump_csv);
72+
int8_t dump_csv);
7373
};
7474

7575
#endif // FEATURE_EXTRACTOR_H

contextual-classifier/Include/FeaturePruner.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ class FeaturePruner {
3030

3131
static void normalize_numbers_inplace(std::vector<std::string> &tokens);
3232

33-
static bool isDigitsOnly(const std::string &str);
33+
static int8_t isDigitsOnly(const std::string &str);
3434

35-
static bool hasDigit(const std::string &str);
35+
static int8_t hasDigit(const std::string &str);
3636

37-
static bool isAllSpecialChars(const std::string &token);
37+
static int8_t isAllSpecialChars(const std::string &token);
3838

3939
static std::string removeDatesAndTimesFromToken(const std::string &input);
4040

4141
static std::string removePunctuation(const std::string &s);
4242

43-
static bool isSingleCharToken(const std::string &s);
43+
static int8_t isSingleCharToken(const std::string &s);
4444

4545
static std::unordered_map<std::string, std::unordered_set<std::string>>
4646
loadIgnoreMap(const std::string &filename,

contextual-classifier/MLInference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ CC_TYPE MLInference::Classify(pid_t processPid) {
201201
return contextType;
202202
}
203203

204-
bool has_sufficient_features = false;
204+
int8_t has_sufficient_features = false;
205205
for (const auto &kv : rawData) {
206206
if (!kv.second.empty()) {
207207
has_sufficient_features = true;

tests/Component/ContextClassificationTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ std::vector<TestAppConfig> loadAppConfigs(const std::string& configPath) {
8181

8282
std::string line;
8383
TestAppConfig currentApp;
84-
bool inApp = false;
84+
int8_t inApp = false;
8585

8686
// Parse line by line
8787
while (std::getline(file, line)) {
@@ -374,7 +374,7 @@ URM_TEST(TestApplicationClassification, {
374374
std::cout << LOG_BASE << "Category: " << categoryName << std::endl;
375375

376376
// Compare predicted label with expected label
377-
bool correct = (predictedLabel == app.expectedLabel);
377+
int8_t correct = (predictedLabel == app.expectedLabel);
378378
std::cout << LOG_BASE << "Match: " << (correct ? "YES" : "NO") << std::endl;
379379

380380
// Cleanup: terminate spawned process

tests/Component/Trigger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ URM_REGISTER_CONFIG(PROPERTIES_CONFIG, "/etc/urm/tests/configs/PropertiesConfig.
1111
URM_REGISTER_CONFIG(SIGNALS_CONFIG, "/etc/urm/tests/configs/SignalsConfig.yaml")
1212
URM_REGISTER_CONFIG(TARGET_CONFIG, "/etc/urm/tests/configs/TargetConfig.yaml")
1313
URM_REGISTER_CONFIG(INIT_CONFIG, "/etc/urm/tests/configs/InitConfig.yaml")
14+
URM_REGISTER_CONFIG(APP_CONFIG, "/etc/urm/tests/configs/PerApp.yaml")
1415

1516
REGISTER_AND_TRIGGER_SUITE(TEST_CLASS)

0 commit comments

Comments
 (0)