philosophers_prep/QUICK_START.sh

168 lines
6.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Quick Start Demo - Shows how to use the test suite
echo "╔════════════════════════════════════════════════════════╗"
echo "║ Philosophers Preparation - Test Suite Demo ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}📚 Este é um guia rápido de como usar os testers${NC}"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}1⃣ Setup Inicial${NC}"
echo " Execute uma vez para configurar:"
echo ""
echo -e " ${YELLOW}bash setup_testers.sh${NC}"
echo ""
echo " Isso irá:"
echo " - Tornar todos os scripts executáveis"
echo " - Verificar dependências (gcc, valgrind, etc.)"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}2⃣ Workflow de Desenvolvimento${NC}"
echo ""
echo " a) Implemente um exercício (ex: thread_basics.c)"
echo ""
echo " b) Compile:"
echo -e " ${YELLOW}gcc -Wall -Wextra -Werror -pthread thread_basics.c -o thread_basics${NC}"
echo ""
echo " c) Teste:"
echo -e " ${YELLOW}bash testers/test_1_thread_basics.sh${NC}"
echo ""
echo " d) Corrija erros e repita"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}3⃣ Testar Exercício Específico${NC}"
echo ""
echo " Opção 1 - Direto:"
echo -e " ${YELLOW}bash testers/test_1_thread_basics.sh${NC}"
echo ""
echo " Opção 2 - Via runner:"
echo -e " ${YELLOW}bash testers/run_all_tests.sh 1${NC}"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}4⃣ Testar Todos os Exercícios${NC}"
echo ""
echo -e " ${YELLOW}bash testers/run_all_tests.sh${NC}"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}5⃣ Exemplo Prático${NC}"
echo ""
echo " Vamos simular o workflow do Exercício 1:"
echo ""
# Check if thread_basics exists
if [ -f "./thread_basics" ]; then
echo -e " ${GREEN}${NC} Executável thread_basics encontrado!"
echo ""
echo " Executando teste..."
echo ""
bash testers/test_1_thread_basics.sh
else
echo -e " ${YELLOW}${NC} Executável thread_basics não encontrado"
echo ""
echo " Para testar de verdade:"
echo ""
echo " 1. Crie thread_basics.c"
echo " 2. Compile: gcc -Wall -Wextra -Werror -pthread thread_basics.c -o thread_basics"
echo " 3. Execute: bash testers/test_1_thread_basics.sh"
fi
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}6⃣ Recursos Adicionais${NC}"
echo ""
echo " 📖 Documentação completa:"
echo -e " ${YELLOW}cat testers/README.md${NC}"
echo ""
echo " 📊 Cobertura de testes:"
echo -e " ${YELLOW}cat testers/TEST_COVERAGE.md${NC}"
echo ""
echo " 📝 Resumo geral:"
echo -e " ${YELLOW}cat TESTERS_SUMMARY.md${NC}"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}7⃣ Debugging${NC}"
echo ""
echo " Se um teste falhar:"
echo ""
echo " Memory Leaks:"
echo -e " ${YELLOW}valgrind --leak-check=full ./seu_programa${NC}"
echo ""
echo " Data Races:"
echo -e " ${YELLOW}valgrind --tool=helgrind ./seu_programa${NC}"
echo ""
echo " Thread Sanitizer:"
echo -e " ${YELLOW}gcc -fsanitize=thread -g programa.c -pthread -o programa_tsan${NC}"
echo -e " ${YELLOW}./programa_tsan${NC}"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}8⃣ Lista de Exercícios${NC}"
echo ""
echo " 1 - thread_basics (Threads básicas)"
echo " 2 - mutex_basics (Mutex e proteção)"
echo " 3 - precise_timing (Timing preciso)"
echo " 4 - state_monitor (Monitor de estados)"
echo " 5 - producer_consumer (Produtor-Consumidor)"
echo " 6 - deadlock_demo (Deadlock)"
echo " 7 - limited_resources (Recursos limitados)"
echo " 8 - simple_philosophers (Filósofos simples)"
echo " 9 - death_monitor (Monitor de morte)"
echo " 10 - philosophers_args (Filósofos completo)"
echo " 11 - race_detector (Detector de races)"
echo " 12 - philosophers_bonus (Bonus com processos)"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${BLUE}💡 Dicas:${NC}"
echo ""
echo " • Comece pelos exercícios 1-3 (fundamentos)"
echo " • Leia os arquivos .txt de cada exercício"
echo " • Teste continuamente enquanto desenvolve"
echo " • Use valgrind e helgrind regularmente"
echo " • Exercícios 8-10 são os mais importantes"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo -e "${GREEN}✨ Pronto para começar!${NC}"
echo ""
echo "Execute o setup:"
echo -e "${YELLOW}bash setup_testers.sh${NC}"
echo ""
echo "Boa sorte! 🚀"
echo ""