Created
March 14, 2019 18:52
-
-
Save ecomaikgolf/19a2ad17e8841b76b15375df8bea583d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <time.h> | |
#include <random> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <thread> | |
#include <chrono> | |
#include <vector> | |
using namespace std; | |
const int MTEXT = 25; | |
const int MINCONT = 100; | |
const int SHIPCONT = 5; | |
const int SHIPWEIGHT = 500; | |
int main(){ | |
system("rm ./datos-entrada/fuzztest.txt"); | |
system("rm ./salida-correcta-esperada/fuzztest.salida-correcta-esperada"); | |
system("touch ./datos-entrada/fuzztest.txt"); | |
system("rm prac1"); | |
ifstream corrector("prac1"); | |
if(!corrector.good()){ | |
system("wget https://www.dlsi.ua.es//asignaturas/p2/downloads/1819/practicas/pr1/prac1 --quiet -O prac1 > /dev/null"); | |
cout << "[!] Introduce la contrasenya para hacer chmod" << endl; | |
system("sudo chmod +x prac1"); | |
} | |
corrector.close(); | |
std::this_thread::sleep_for(std::chrono::seconds(3)); | |
ofstream of("./datos-entrada/fuzztest.txt"); | |
if(!of.is_open()) return -1; | |
srand(time(NULL)); | |
int iteraciones; | |
cout << "[-] Introduce el numero de iteraciones: "; | |
cin >> iteraciones; | |
vector<string> nombres; | |
for(int i = 0 ; i < iteraciones; i++){ | |
int randValue = rand()%10; | |
switch(randValue){ | |
case 1: | |
{ | |
of << 1 << '\n'; | |
break; | |
} | |
case 2: | |
{ | |
of << 2 << '\n'; | |
int weight = rand()%1000; | |
of << weight << '\n'; | |
if(weight >= MINCONT){ | |
of << rand()%10000 << '\n'; | |
} | |
break; | |
} | |
case 3: | |
{ | |
of << 3 << '\n'; | |
of << rand()%100 << '\n'; | |
break; | |
} | |
case 4: | |
{ | |
of << 4 << '\n'; | |
string name = ""; | |
for(int i = 0; i < MTEXT;i++){ | |
name += 'A' + rand()%26; | |
} | |
nombres.push_back(name); | |
of << name << '\n'; | |
int ncont = rand()%100; | |
if(ncont >= SHIPCONT){ | |
of << ncont << '\n'; | |
of << rand()%10000 << '\n'; | |
} | |
break; | |
} | |
case 5: | |
{ | |
of << 5 << '\n'; | |
int nrand = rand()%(nombres.size()-1); | |
of << nombres[nrand] << '\n'; | |
break; | |
} | |
case 6: | |
break; | |
case 7: | |
{ | |
of << 7 << '\n'; | |
break; | |
} | |
} | |
} | |
of << 'q' << '\n'; | |
of.close(); | |
cout << "Fin" << endl; | |
system("./prac1 < datos-entrada/fuzztest.txt > salida-correcta-esperada/fuzztest.salida-correcta-esperada"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment